Re: diff between packages and modules
R == R Joseph Newton [EMAIL PROTECTED] writes: R Message-ID: [EMAIL PROTECTED] R [Randal] R ... R The point is that R $instance-new R could mean either clone, or make one of the same class as. You R don't need it for make one of the same class as, because you've got: R (ref $instance)-new R to do that explicitly. And if you really wanted that to do clone, R CALL IT CLONE, don't call it -new. R It obscures more than it clarifies, and hence is a *bad* name R for an instance method. R ... R [/Randal] Thanks for reposting that. I'm unwavering on this. I've heard all counter arguments, and am unconvinced. So I continue to argue that -new is a *class* method only. This is not to say that I believe methods can't be both class and instance methods. In perldoc perlboot, I show a sensible use of such methods. It's just that particularly, -new on an instance can mean either clone or make an empty one of the same class as, and since it can easily mean either, it's best not to burden -new with double duty when it only adds confusion. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Win32 Registry
Easy there. Before we start using the 'V' word, lets just step back for a second. First of all, there is absolutely nothing wrong with putting a program in the Run key, and it is in fact a bad idea to tell people to categorically delete anything in that key. I would agree that viruses and other programs often use this key, and it is a good idea to familiarize yourself with the legitimate contents of this key. Creaing a service for any program that needs to run at startup is overkill, and actually can be counterproductive, since the majority of non-OS programs should be run in the user context instead of the system context, but this is really a discussion for another forum. Now on to the actual question: I'm going to assume that the OP has already done his research for now and knows for sure that he wants to delete the key in quesion, and avoid the standard lecture on why you should be VERY SURE that you want to do this before you start deleting keys. The way you would actually do this would be via a line like this: my $result = delete $Registry-{'HKEY_LOCAL_MACHINE/SOFTWARE/Tim/MyKey/'}; Of course, this only works if there are no subkeys, so you will have to work your way back from the deepest key if there are subkeys. Also, I really recommend reading the documentation on the module. Perldoc Win32::TieRegistry -Original Message- From: R. Joseph Newton [mailto:[EMAIL PROTECTED] Sent: Saturday, December 20, 2003 1:24 PM To: Tim Johnson Cc: Jeff Westman; perl_help Subject: Re: Win32 Registry Tim Johnson wrote: Win32::TieRegistry will do what you want. use Win32::TieRegistry (delimiter = '/'); my $run = $Registry-{'HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Run'}; $run-{'MyApp'} = My Application; etc., etc. That looks like a good example of the crap that we need to scour from our registries. Please don't recommend virus-like program behaviors. A well-managed Windows machine should have nothing--zilch--nada--in this key. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: deallocating?
Christopher J Bottaro wrote: just for practice, i made a class BinaryTree. its just a blessed reference to a hash that contains two things: size and root. root gets assigned to a BinaryTree::Node which is just a bless reference containing: key, value, left, right. perl deallocates according to reference counts. so if i want destory my tree structure, i'd have to make sure there are no references to any of the BinaryTree::Node's, right? something like this... $my pr_clear; ^ You have the '$' in the wrong place, it should be: my $pr_clear; $pr_clear = sub { my $p = shift(); # parent node my $w = shift(); # which child of the parent my $n = shift(); # child node if ($n != undef){ You cannot use undef in a comparison, use the defined function to determine if a scalar is defined or not. if ( not defined $n ) { this-$pr_clear($n, left, $n-left()); ^ this-$pr_clear($n, right, $n-right()); ^ $p-$w(undef); ^ You have the '$' in the wrong place, it should be: $this-pr_clear($n, left, $n-left()); $this-pr_clear($n, right, $n-right()); $p-w(undef); } } sub clear() { this-$pr_clear(this-{root}, left, this-{root}-left()); ^ ^ this-$pr_clear(this-{root}, right, this-{root}-right()); ^ ^ this-{root} = undef; ^ You have the '$' in the wrong place, it should be: $this-pr_clear(this-{root}, left, $this-{root}-left()); $this-pr_clear(this-{root}, right, $this-{root}-right()); $this-{root} = undef; If you want to remove the key 'root' then use delete(). delete $this-{root}; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How to write a page break character.
Chetak Sasalu wrote: I want to search for the word status in a group of files in a directory and replace it with status\n^L where ^L is a page break chatacter, In vi I can type it in using cntrl+l. if you really want to 'type' it in, you can type C-vC-l you can insert tabs in a regex with ctrl-v, too. // George -- GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027IXOYE Security Services, Web, Mail,mailto:[EMAIL PROTECTED] Multimedia, DB, DNS and Metrics. http://www.galis.org/george -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: deallocating?
christopher j bottaro wrote: just for practice, i made a class BinaryTree. its just a blessed reference to a hash that contains two things: size and root. root gets assigned to a BinaryTree::Node which is just a bless reference containing: key, value, left, right. perl deallocates according to reference counts. so if i want destory my tree structure, i'd have to make sure there are no references to any of the BinaryTree::Node's, right? Nope. Try $root = undef; something like this... $my pr_clear; $pr_clear = sub { my $p = shift(); # parent node my $w = shift(); # which child of the parent my $n = shift(); # child node if ($n != undef){ this-$pr_clear($n, left, $n-left()); this-$pr_clear($n, right, $n-right()); $p-$w(undef); } } sub clear() { this-$pr_clear(this-{root}, left, this-{root}-left()); this-$pr_clear(this-{root}, right, this-{root}-right()); this-{root} = undef; } thanks in advance, and thanks to those who helped with the module questions, -- christopher Looks like a good structure for doing the chore in C++, though. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: deallocating?
NYIMI Jose (BMB) wrote: Did you read this ? http://www.perl.com/lpt/a/2002/08/07/proxyobject.html José. Hi Jose, Actually, if christopher is accurately reporting his class structures, this article should not relate. He reports only one-way references, wherein Mommy watches her kids, and they need not concern themselves with her identity. Therefore, there is no circularity to dissolve. All he needs to do is undef the root. I think the disccusion, though, is taking on a circular aspect, since we covered this same territory sometime in the past couple weeks. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: deallocating?
Yes, you right. José. -Original Message- From: R. Joseph Newton [mailto:[EMAIL PROTECTED] Sent: Sunday, December 21, 2003 6:18 PM To: NYIMI Jose (BMB) Cc: christopher j bottaro; [EMAIL PROTECTED] Subject: Re: deallocating? NYIMI Jose (BMB) wrote: Did you read this ? http://www.perl.com/lpt/a/2002/08/07/proxyobject.html José. Hi Jose, Actually, if christopher is accurately reporting his class structures, this article should not relate. He reports only one-way references, wherein Mommy watches her kids, and they need not concern themselves with her identity. Therefore, there is no circularity to dissolve. All he needs to do is undef the root. I think the disccusion, though, is taking on a circular aspect, since we covered this same territory sometime in the past couple weeks. Joseph DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Andrew Gaffney wrote: I want to write a Perl program that will auto generate GIF images. The images that I want to generate will be about 30x80. It will be a black rectangle starting in the bottom-right with a few pixels border on the top and left. There will be a light blue rectangle starting in the top-left with a few pixels border on the bottom and right. There will then be 6- or 8-point black bold centered text that will be specified when the program is run. The background also need to be transparent. Can anyone give me any pointers on writing a Perl program that can do what I need? Links to examples are good too. Thanks. -- Andrew Gaffney Is this production work? If so, use a module. Perl has a pretty wide choice in graphics modules, and Daniel provided a good starting point in his response above. If you are interested in hand-cracking this, the best place to start is with the GIF links on this page: http://www.dcs.ed.ac.uk/home/mxr/gfx/2d-hi.html They are very links to the best, primary-source, information on GIFfery. The three links include the original specifications for both versions 87a and 89a, as well as an essay on the compression and decompression algorithms. Some tips if you do take the hand-crank route: 1. Be aware that the marketbility of any product you make could be problematic. In many nations, Unisys Corp. still holds and asserts a patent on LZW compression. They held a patent in the USA until June of this year, when it expired. ***!!! Yippeee !!! So there may be licensing issues if you distribute outside the USA, or are located in a country where the patent is in effect. 2. Start with images that come out under 254 bytes compressed. It sounds like your anticipated use will fit well under that. There are some rollover issues that arise when you start new coding chains within an image, so its better to get the coding working on smaller images, then work up to deal with the where is the start of this next coding segment? issues. 3. Make objects to represent the various types of blocks within a structure. This will make each more modular and allow for better self-management. Some blocks are optional, others are version-specific, others may exist or not based on the value of a flag in the descriptors. You will want to be ready for interpreting each block as it comes, and keep the interfaces between you functions and objects very clean. It is all too easy to slip by a few bits and totally hose the encoding/decoding. Good luck. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
zentara wrote: On Sat, 20 Dec 2003 14:23:15 -0600, [EMAIL PROTECTED] (Andrew Gaffney) wrote: I want to write a Perl program that will auto generate GIF images. The images that I want to generate will be about 30x80. It will be a black rectangle starting in the bottom-right with a few pixels border on the top and left. There will be a light blue rectangle starting in the top-left with a few pixels border on the bottom and right. There will then be 6- or 8-point black bold centered text that will be specified when the program is run. The background also need to be transparent. Can anyone give me any pointers on writing a Perl program that can do what I need? Links to examples are good too. Thanks. Well, gifs were shunned by alot of the software writers because of the old patent issues. So your best bet will be to make your image as a jpg or png, then convert it to gif afterwards. Is PNG a good format for a 51x20 image with 4 or 5 colors? If you want to make an animated gif, you can use something like this: system(gifsicle -lforever $graphical*.gif $graphical.anim.gif) I've used gifsicle before to make animated GIFs. That was a nifty little program. -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Andrew Gaffney writes: zentara wrote: Well, gifs were shunned by alot of the software writers because of the old patent issues. So your best bet will be to make your image as a jpg or png, then convert it to gif afterwards. Is PNG a good format for a 51x20 image with 4 or 5 colors? If you want to make an animated gif, you can use something like this: system(gifsicle -lforever $graphical*.gif $graphical.anim.gif) I've used gifsicle before to make animated GIFs. That was a nifty little program. Is there any alternative to gifs to make animated images? Flash is proprietary to macromedia, and gif to Unisys. Is there such a thing as an animated png? How about a free (in the GPL sense) open sourced alternative to Flash? -- And there came a writing to him from Elijah [2Ch 21:12] R. J. Brown III [EMAIL PROTECTED] http://www.elilabs.com/~rj voice 859 567-7311 Elijah Laboratories Inc.P. O. Box 166, Warsaw KY 41095fax 859 567-7311 - M o d e l i n g t h e M e t h o d s o f t h e M i n d -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: deallocating?
On Sunday 21 December 2003 11:07 am, R. Joseph Newton wrote: Nope. Try $root = undef; interesting. so perl is smart enough to know that once root is undef, the user has no way of reaching any of the nodes in the tree, even if those nodes still have references to them (i.e. the parent nodes left and right hash entries). if thats the case...wow, i'm impressed...=) thanks, -- christopher -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
zentara wrote: On Sat, 20 Dec 2003 14:23:15 -0600, [EMAIL PROTECTED] (Andrew Gaffney) wrote: I want to write a Perl program that will auto generate GIF images. The images that I want to generate will be about 30x80. It will be a black rectangle starting in the bottom-right with a few pixels border on the top and left. There will be a light blue rectangle starting in the top-left with a few pixels border on the bottom and right. There will then be 6- or 8-point black bold centered text that will be specified when the program is run. The background also need to be transparent. Can anyone give me any pointers on writing a Perl program that can do what I need? Links to examples are good too. Thanks. Well, gifs were shunned by alot of the software writers because of the old patent issues. So your best bet will be to make your image as a jpg or png, then convert it to gif afterwards. If you want to make an animated gif, you can use something like this: system(gifsicle -lforever $graphical*.gif $graphical.anim.gif) Here is a simple script using GD. snip I wrote my own script based off your example and the docs at http://search.cpan.org/~lds/GD-2.11/GD.pm. When I run the below program, I get: skyline skyline-src # ./genbutton.pl gd-png: fatal libpng error: Invalid number of colors in palette gd-png error: setjmp returns error condition Here is my code: #!/usr/bin/perl use warnings; use GD; $im = new GD::Image-new(51, 20); $gray = $im-colorClosest(127, 127, 127); $blue = $im-colorClosest(0, 0, 127); $white = $im-colorClosest(255, 255, 255); $black = $im-colorClosest(0, 0, 0); $im-transparent($white); $im-filledRectangle(0, 0, 51, 20, $white); # Transparent background fill $im-filledRectangle(4, 4, 51, 20, $gray); $im-filledRectangle(0, 0, 47, 16, $blue); $im-string(gdSmallFont, 3, 3, Test, $black); open(PNG, /home/httpd/htdocs/testbutton.png) or die Can't write GDtest.png: !\en; binmode (PNG); print PNG $im-png; close(PNG); -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Win32 Registry
Tim Johnson wrote: Easy there. Before we start using the 'V' word, lets just step back for a second. First of all, there is absolutely nothing wrong with putting a program in the Run key, and it is in fact a bad idea to tell people to categorically delete anything in that key. I would agree that viruses and other programs often use this key, and it is a good idea to familiarize yourself with the legitimate contents of this key. Creaing a service for any program that needs to run at startup is overkill, and actually can be counterproductive, since the majority of non-OS programs should be run in the user context instead of the system context, but this is really a discussion for another forum. I agree that I was overstating the case--slightly. I was looking at the right subkey, but under the wrong key, HKEY_CURRENT_USER, when I said that. When I looked at the actual key I cited, I did see four values. One, the system-tray icon for my antivirus, is convenient. Another, the Synchronization Manager, was something I specifically requested by turning on the offline files feature. The other two were Iomega cats my zip drive drug in--imgicon.exe and another exe that seems to run and exit at startup. None of these is at all indispensable, and I run some pretty heavy-duty productivity applications. So while my statement may have involved a bit of hyperbole, I will basically stick with it. Now on to the actual question: I'm going to assume that the OP has already done his research for now and knows for sure that he wants to delete the key in quesion, and avoid the standard lecture on why you should be VERY SURE that you want to do this before you start deleting keys. The way you would actually do this would be via a line like this: my $result = delete $Registry-{'HKEY_LOCAL_MACHINE/SOFTWARE/Tim/MyKey/'}; Of course, this only works if there are no subkeys, so you will have to work your way back from the deepest key if there are subkeys. Also, I really recommend reading the documentation on the module. Perldoc Win32::TieRegistry Sorry, Tim, but there is way more to it than that. Have you ever tried to remove the vestiges of a failed install/uninstall, particularly on a large, multi-application suite. The keys and values set are not at all so neatly placed. They can be found all over the Registry. If left in place, some of them can cause very persistent, subtle, and vexing problems. There are legitimate purposes for many of these settings. File types must be associated. DLLs must be registered, etc. Some though, seem to exist for no other purpose than to insinuate the software inextricably in the system. I really don't think there is any way one could successfully code a Registry scour to clean out a bad uninstall until one has done it by hand. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Andrew Gaffney wrote: I wrote my own script based off your example and the docs at http://search.cpan.org/~lds/GD-2.11/GD.pm. When I run the below program, I get: skyline skyline-src # ./genbutton.pl gd-png: fatal libpng error: Invalid number of colors in palette gd-png error: setjmp returns error condition Here is my code: #!/usr/bin/perl use warnings; use GD; $im = new GD::Image-new(51, 20); $gray = $im-colorClosest(127, 127, 127); $blue = $im-colorClosest(0, 0, 127); $white = $im-colorClosest(255, 255, 255); $black = $im-colorClosest(0, 0, 0); $im-transparent($white); $im-filledRectangle(0, 0, 51, 20, $white); # Transparent background fill By putting in a bunch of print and die statements, I've determined the problem is at the line above. I still get the error if I comment out the line that sets white as transparent above. $im-filledRectangle(4, 4, 51, 20, $gray); $im-filledRectangle(0, 0, 47, 16, $blue); $im-string(gdSmallFont, 3, 3, Test, $black); open(PNG, /home/httpd/htdocs/testbutton.png) or die Can't write GDtest.png: !\en; binmode (PNG); print PNG $im-png; close(PNG); -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
--As off Sunday, December 21, 2003 11:59 AM -0600, Robert Brown is alleged to have said: Is there any alternative to gifs to make animated images? Flash is proprietary to macromedia, and gif to Unisys. Is there such a thing as an animated png? How about a free (in the GPL sense) open sourced alternative to Flash? --As for the rest, it is mine. There is an animated variant of png, mng. I am not sure what the support level is (besides that Mozilla recently dropped it), but it doesn't sound to hard if the program already supports png... Or there is SVG, which is closer to Flash than anything else. Browser support is limited though, at least without a plugin. (Of course, Flash needs a plugin too...) Daniel T. Staal --- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Daniel Staal writes: --As off Sunday, December 21, 2003 11:59 AM -0600, Robert Brown is alleged to have said: Is there any alternative to gifs to make animated images? Flash is proprietary to macromedia, and gif to Unisys. Is there such a thing as an animated png? How about a free (in the GPL sense) open sourced alternative to Flash? --As for the rest, it is mine. There is an animated variant of png, mng. I am not sure what the support level is (besides that Mozilla recently dropped it), but it doesn't sound to hard if the program already supports png... Or there is SVG, which is closer to Flash than anything else. Browser support is limited though, at least without a plugin. (Of course, Flash needs a plugin too...) Daniel T. Staal Thanks! It would seem that non-proprietary support for animated graphics, or better yet animated graphics synchronized to sound, ala Flash, would be a likely candidate for an open source development project. Too bad, but my skills are not strong in that area, although I do have some MPEG-2 video decoder experience. My experience has mostly been involved with real-time and embeddded OS development, and telephony stuff. -- And there came a writing to him from Elijah [2Ch 21:12] R. J. Brown III [EMAIL PROTECTED] http://www.elilabs.com/~rj voice 859 567-7311 Elijah Laboratories Inc.P. O. Box 166, Warsaw KY 41095fax 859 567-7311 - M o d e l i n g t h e M e t h o d s o f t h e M i n d -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Andrew Gaffney wrote: zentara wrote: On Sat, 20 Dec 2003 14:23:15 -0600, [EMAIL PROTECTED] (Andrew Gaffney) wrote: I want to write a Perl program that will auto generate GIF images. The images that I want to generate will be about 30x80. It will be a black rectangle starting in the bottom-right with a few pixels border on the top and left. There will be a light blue rectangle starting in the top-left with a few pixels border on the bottom and right. There will then be 6- or 8-point black bold centered text that will be specified when the program is run. The background also need to be transparent. Can anyone give me any pointers on writing a Perl program that can do what I need? Links to examples are good too. Thanks. Well, gifs were shunned by alot of the software writers because of the old patent issues. So your best bet will be to make your image as a jpg or png, then convert it to gif afterwards. If you want to make an animated gif, you can use something like this: system(gifsicle -lforever $graphical*.gif $graphical.anim.gif) Here is a simple script using GD. snip I wrote my own script based off your example and the docs at http://search.cpan.org/~lds/GD-2.11/GD.pm. When I run the below program, I get: skyline skyline-src # ./genbutton.pl gd-png: fatal libpng error: Invalid number of colors in palette gd-png error: setjmp returns error condition Here is my code: #!/usr/bin/perl use warnings; use GD; $im = new GD::Image-new(51, 20); $gray = $im-colorClosest(127, 127, 127); $blue = $im-colorClosest(0, 0, 127); $white = $im-colorClosest(255, 255, 255); $black = $im-colorClosest(0, 0, 0); $im-transparent($white); $im-filledRectangle(0, 0, 51, 20, $white); # Transparent background fill $im-filledRectangle(4, 4, 51, 20, $gray); $im-filledRectangle(0, 0, 47, 16, $blue); $im-string(gdSmallFont, 3, 3, Test, $black); open(PNG, /home/httpd/htdocs/testbutton.png) or die Can't write GDtest.png: !\en; binmode (PNG); print PNG $im-png; close(PNG); -- Andrew Gaffney You must have 2 ** bit-per-pixel colors for the palette. You need not use them all, but they need to be defined, or it throws the coding process off. Fill the blanks with white, or use: 00 R: 000 G: 000 B: 000 01 R: 128 G: 000 B: 000 02 R: 000 G: 128 B: 000 03 R: 128 G: 128 B: 000 04 R: 000 G: 000 B: 128 05 R: 128 G: 000 B: 128 06 R: 000 G: 128 B: 128 07 R: 192 G: 192 B: 192 08 R: 128 G: 128 B: 128 09 R: 255 G: 000 B: 000 10 R: 000 G: 255 B: 000 11 R: 255 G: 255 B: 000 12 R: 000 G: 000 B: 255 13 R: 255 G: 000 B: 255 14 R: 000 G: 255 B: 255 15 R: 255 G: 255 B: 255 To give yourself a nice broad-spectrum selection of colors. The compression aogorithm is based around string table inidices, which must start at the right place. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: generating GIFs
Andrew Gaffney [EMAIL PROTECTED] wrote: : : I wrote my own script based off your example and the docs : at http://search.cpan.org/~lds/GD-2.11/GD.pm. When I : run the below program, I get: : : : skyline skyline-src # ./genbutton.pl : gd-png: fatal libpng error: Invalid number of colors in palette : gd-png error: setjmp returns error condition You haven't set the palette. You need to Allocate() colors into the palette before you can choose the Closest() color in the palette. I changed $blue to $green. It was easier to see the text that way. my $im = new GD::Image-new(51, 20); my $gray= $im-colorAllocate( 127, 127, 127 ); my $green = $im-colorAllocate( 0, 190, 200 ); my $white = $im-colorAllocate( 255, 255, 255 ); my $black = $im-colorAllocate( 0, 0, 0 ); $im-transparent($white); $im-filledRectangle( 0, 0, 51, 20, $white ); $im-filledRectangle( 4, 4, 51, 20, $gray ); $im-filledRectangle( 0, 0, 47, 16, $green ); $im-string( gdSmallFont, 3, 3, Test, $black ); my $png = 'testbutton.png'; open PNG, /home/httpd/htdocs/$png or die qq|Can't write $png: $!|; binmode PNG; print PNG $im-png; close PNG; HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: where to look for modules?
On Saturday 20 December 2003 05:05 am, Owen wrote: I think the easiest for you would be to; use Modules; # as found in /usr/lib/perl5/5.8.0/ use lib '/home/cjb/perlmodules'; #followed by use MyModule; #and/or any other module you have there great, that worked perfectly...=) i'm having a hard time finding documentation for use lib. i looked at use in perlfunc and i also looked at perlmodlib. thanks, -- christopher -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: where to look for modules?
Just type perldoc lib HTH, José. -Original Message- From: christopher j bottaro [mailto:[EMAIL PROTECTED] Sent: Sunday, December 21, 2003 8:50 PM To: [EMAIL PROTECTED] Subject: Re: where to look for modules? On Saturday 20 December 2003 05:05 am, Owen wrote: I think the easiest for you would be to; use Modules; # as found in /usr/lib/perl5/5.8.0/ use lib '/home/cjb/perlmodules'; #followed by use MyModule; #and/or any other module you have there great, that worked perfectly...=) i'm having a hard time finding documentation for use lib. i looked at use in perlfunc and i also looked at perlmodlib. thanks, -- christopher -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Charles K. Clarkson wrote: Andrew Gaffney [EMAIL PROTECTED] wrote: : : I wrote my own script based off your example and the docs : at http://search.cpan.org/~lds/GD-2.11/GD.pm. When I : run the below program, I get: : : : skyline skyline-src # ./genbutton.pl : gd-png: fatal libpng error: Invalid number of colors in palette : gd-png error: setjmp returns error condition You haven't set the palette. You need to Allocate() colors into the palette before you can choose the Closest() color in the palette. I changed $blue to $green. It was easier to see the text that way. I have reworked my script using another example I found and it works correctly for the most part, now. #!/usr/bin/perl use GD; $im = new GD::Image(51,20); $white = $im-colorAllocate(255,255,255); $black = $im-colorAllocate(0,0,0); $gray = $im-colorAllocate(132,132,132); $blue = $im-colorAllocate(206,206,255); $leftblue = $im-colorAllocate(231,231,255); $bottomblue = $im-colorAllocate(165,165,206); $rightblue = $im-colorAllocate(123,123,156); $topblue = $im-colorAllocate(214,214,255); $im-transparent($white); $im-interlaced('true'); $im-filledRectangle(0,0,50,19,$white); $im-filledRectangle(3,3,50,19,$gray); $im-filledRectangle(0,0,47,16,$blue); $im-rectangle(0,0,47,16,$white); $im-line(1,0,46,0,$topblue); $im-line(47,1,47,15,$rightblue); $im-line(1,16,46,16,$bottomblue); $im-line(0,1,0,15,$leftblue); $im-string(gdSmallFont, 2, 2, Contact, $black); open IMAGE, /home/httpd/htdocs/testbutton.png; binmode IMAGE; print IMAGE $im-png; close IMAGE; The resulting image is http://www.skylineaero.com/testbutton.png. I was modeling the image after one I had previously done using Paint Shop Pro at http://www.skylineaero.com/contactusbutton.gif. They look pretty darn similar except for the text. Can anyone recommend a way to make the generated text (testbutton.png) look like the text in the hand-made one (contactusbutton.gif)? Also, since this will be a script to auto-generate these images with user-defined text, how can I center the text in the image (or even in the blue rectangle)? Should I use a different module for generating the text, or even for generating the whole image? -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Andrew Gaffney writes: The resulting image is http://www.skylineaero.com/testbutton.png. I was modeling the image after one I had previously done using Paint Shop Pro at http://www.skylineaero.com/contactusbutton.gif. They look pretty darn similar except for the text. Can anyone recommend a way to make the generated text (testbutton.png) look like the text in the hand-made one (contactusbutton.gif)? Also, since this will be a script to auto-generate these images with user-defined text, how can I center the text in the image (or even in the blue rectangle)? Should I use a different module for generating the text, or even for generating the whole image? I think the second one -- the perl generated one -- is the more readable of the two. :-/ -- And there came a writing to him from Elijah [2Ch 21:12] R. J. Brown III [EMAIL PROTECTED] http://www.elilabs.com/~rj voice 859 567-7311 Elijah Laboratories Inc.P. O. Box 166, Warsaw KY 41095fax 859 567-7311 - M o d e l i n g t h e M e t h o d s o f t h e M i n d -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: generating GIFs
Andrew Gaffney [EMAIL PROTECTED] wrote: : Can anyone recommend a way to make the generated text : (testbutton.png) look like the text in the hand-made : one (contactusbutton.gif)? Also, since this will be a : script to auto-generate these images with user-defined : text, how can I center the text in the image (or even : in the blue rectangle)? Should I use a different : module for generating the text, or even for generating : the whole image? Take a look at the stringTTF() method. It allows you to choose a TrueType font and returns the bounds of the string. Using the string boundaries, you might then be able to center the string in a box. HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Robert Brown wrote: Andrew Gaffney writes: The resulting image is http://www.skylineaero.com/testbutton.png. I was modeling the image after one I had previously done using Paint Shop Pro at http://www.skylineaero.com/contactusbutton.gif. They look pretty darn similar except for the text. Can anyone recommend a way to make the generated text (testbutton.png) look like the text in the hand-made one (contactusbutton.gif)? Also, since this will be a script to auto-generate these images with user-defined text, how can I center the text in the image (or even in the blue rectangle)? Should I use a different module for generating the text, or even for generating the whole image? I think the second one -- the perl generated one -- is the more readable of the two. :-/ If by 'second one', you mean the new one, not the one I reference second, then yes, I agree. I'm thinking about making the image a bit wider to accomidate a bit more text. I still need to figure out how to center the text. -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: where to look for modules?
On Sun, 21 Dec 2003 13:49:59 -0600 christopher j bottaro [EMAIL PROTECTED] wrote: On Saturday 20 December 2003 05:05 am, Owen wrote: I think the easiest for you would be to; use Modules;# as found in /usr/lib/perl5/5.8.0/ use lib '/home/cjb/perlmodules'; #followed by use MyModule; #and/or any other module you have there great, that worked perfectly...=) i'm having a hard time finding documentation for use lib. i looked at use in perlfunc and i also looked at perlmodlib. Like so many others, accessing information out of perldoc is still a bit of mystery to me. However in this case, something popped up with perldoc -q path which might be a start -- Owen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Charles K. Clarkson wrote: Andrew Gaffney [EMAIL PROTECTED] wrote: : Can anyone recommend a way to make the generated text : (testbutton.png) look like the text in the hand-made : one (contactusbutton.gif)? Also, since this will be a : script to auto-generate these images with user-defined : text, how can I center the text in the image (or even : in the blue rectangle)? Should I use a different : module for generating the text, or even for generating : the whole image? Take a look at the stringTTF() method. It allows you to choose a TrueType font and returns the bounds of the string. Using the string boundaries, you might then be able to center the string in a box. I've got this working to some extend, but I'm having a weird problem. About 1 of every 6 times I run the script, it doesn't generate the text and it sets $@ to libgd was not build with FreeType font support which obviously isn't true since it works the other 5 out of 6 times. Anyone know what's going on? -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Andrew Gaffney wrote: Charles K. Clarkson wrote: Andrew Gaffney [EMAIL PROTECTED] wrote: : Can anyone recommend a way to make the generated text : (testbutton.png) look like the text in the hand-made : one (contactusbutton.gif)? Also, since this will be a : script to auto-generate these images with user-defined : text, how can I center the text in the image (or even : in the blue rectangle)? Should I use a different : module for generating the text, or even for generating : the whole image? Take a look at the stringTTF() method. It allows you to choose a TrueType font and returns the bounds of the string. Using the string boundaries, you might then be able to center the string in a box. I've got this working to some extend, but I'm having a weird problem. About 1 of every 6 times I run the script, it doesn't generate the text and it sets $@ to libgd was not build with FreeType font support which obviously isn't true since it works the other 5 out of 6 times. Anyone know what's going on? I think I've fixed this, too. It looks like it was some weird caching issue with Apache and mod_perl. I renamed the script and it works correctly every time now. Thank you for the suggestion to use stringTTF() or stringFT() to generate the text. I was able to use the array returned by it to center the text in the middle of the generated image. Thanks. -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: generating GIFs
Andrew Gaffney wrote: Charles K. Clarkson wrote: Andrew Gaffney [EMAIL PROTECTED] wrote: : Can anyone recommend a way to make the generated text : (testbutton.png) look like the text in the hand-made : one (contactusbutton.gif)? Also, since this will be a : script to auto-generate these images with user-defined : text, how can I center the text in the image (or even : in the blue rectangle)? Should I use a different : module for generating the text, or even for generating : the whole image? Take a look at the stringTTF() method. It allows you to choose a TrueType font and returns the bounds of the string. Using the string boundaries, you might then be able to center the string in a box. I've got this working to some extend, but I'm having a weird problem. About 1 of every 6 times I run the script, it doesn't generate the text and it sets $@ to libgd was not build with FreeType font support which obviously isn't true since it works the other 5 out of 6 times. Anyone know what's going on? I think I've fixed this, too. It looks like it was some weird caching issue with Apache and mod_perl. I renamed the script and it works correctly every time now. Thank you for the suggestion to use stringTTF() or stringFT() to generate the text. I was able to use the array returned by it to center the text in the middle of the generated image. Thanks. -- Andrew Gaffney -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: deallocating?
Does that clear things up? yes, very much so...thank you...=) -- christopher On Sunday 21 December 2003 10:39 pm, James Edward Gray II wrote: Perl uses a reference counting system. That usually does the right thing, like most things Perl. It's not magic, but it sure is handy. Let's look at an example. If I have an object A, which contains a reference to object B, which contains a reference to C, etc: A has a B has a C ... Now if A is the only top level reference in my currently running code (and no other code has references), what happens when we do: A = undef Object A's ref count just hit zero, so it's gone. Now when that garbage collection happens, B's count is reduced, since A's reference to it is reclaimed. If it hits zero too, B will be collected. That would reduce C's count... You get the idea. Basically, you generally only need to worry about Perl's references when you create circular refs. When faced with that, break the chain yourself manually or use weak references. Does that clear things up? James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: deallocating?
James == James Edward Gray [EMAIL PROTECTED] writes: James Object A's ref count just hit zero, so it's gone. Now when that James garbage collection happens, B's count is reduced, since A's reference James to it is reclaimed. If it hits zero too, B will be collected. That James would reduce C's count... You get the idea. James Basically, you generally only need to worry about Perl's references James when you create circular refs. When faced with that, break the chain James yourself manually or use weak references. http://www.stonehenge.com/merlyn/PerlJournal/col04.html -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response