From tony at tvortex.net Fri Aug 1 07:37:03 2008 From: tony at tvortex.net (Tony Simons) Date: Fri, 1 Aug 2008 14:37:03 +0000 Subject: [Omaha.pm] Perl - Print current date as UTC(Zulu) Message-ID: <693a91740808010737t1beb0912r6284a8212357695b@mail.gmail.com> I'm having difficulty figuring out how to converting the current date to Zulu Output date example: 20080731T212151Z Any example that could take in a common input date. example: Fri, 01 Aug 2008 09:35:39 CDT or better. Thanks ~Tony -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Fri Aug 1 19:39:33 2008 From: jay at jays.net (Jay Hannah) Date: Fri, 1 Aug 2008 21:39:33 -0500 Subject: [Omaha.pm] Perl - Print current date as UTC(Zulu) In-Reply-To: <693a91740808010737t1beb0912r6284a8212357695b@mail.gmail.com> References: <693a91740808010737t1beb0912r6284a8212357695b@mail.gmail.com> Message-ID: <1FD4EF05-CA27-4BAD-AE07-C7281A648EFF@jays.net> On Aug 1, 2008, at 9:37 AM, Tony Simons wrote: > I'm having difficulty figuring out how to converting the current > date to Zulu > Output date example: > 20080731T212151Z Any example that could take in a common input > date. example: > > Fri, 01 Aug 2008 09:35:39 CDT Looks like this is working. Hope it helps, j # perl -MCPAN -e 'install Class::Date' # perl -MCPAN -e 'install Date::Parse' $ cat j.pl #!/usr/bin/perl -w use strict; use Class::Date qw(localdate -DateParse); use Date::Parse; my $in_date = localdate(str2time($ARGV[0])); my $out_date = $in_date->to_tz('GMT'); $Class::Date::DATE_FORMAT="%Y%m%dT%H%M%SZ"; print "$out_date\n"; $ perl j.pl "Fri, 01 Aug 2008 09:35:39 CDT" 20080801T143539Z From jay at jays.net Tue Aug 5 17:46:37 2008 From: jay at jays.net (Jay Hannah) Date: Tue, 5 Aug 2008 19:46:37 -0500 Subject: [Omaha.pm] perl -MTest::WWW::Mechanize::Catalyst\ 100 Message-ID: <8FF7E4AA-0BCC-46B2-8DA9-D73ED6E4E55A@jays.net> Here's a neat way of figuring out what version of any given module you have. For example, if I tell Perl that I require Test::WWW::Mechanize::Catalyst version 100 it will fail and report to me what version I actually have: $ perl -MTest::WWW::Mechanize::Catalyst\ 100 Test::WWW::Mechanize::Catalyst version 100 required--this is only version 0.42. BEGIN failed--compilation aborted. Pretty slick, eh? Thanks to rjbs @ YAPC & IRC. :) (This trick isn't nearly as cool as the DBI-specific magic below, but this trick works for ANY module.) j $ perl -MDBI -e 'DBI->installed_versions' Perl : 5.008008 (i586-linux-thread-multi) OS : linux (2.6.16) DBI : 1.601 DBD::mysql : 3.0002 DBD::Sybase : 1.08 DBD::Sponge : 12.010002 DBD::SQLite : 1.14 DBD::Proxy : 0.2004 DBD::Informix : 2007.0914 DBD::Gofer : 0.010103 DBD::File : 0.35 DBD::ExampleP : 12.010007 DBD::DBM : 0.03 From dan at linder.org Wed Aug 6 15:08:58 2008 From: dan at linder.org (Dan Linder) Date: Wed, 6 Aug 2008 17:08:58 -0500 Subject: [Omaha.pm] Pulling in a hash via "exec"...FAIL Message-ID: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> I've got one program that generates a hash and then uses Data::Dump to write this structure to a text file: printf FILE Data::Dumper->Dump(\%fields],['fields']); The resulting file contains this: --- begin contents --- $fields = { 'FIELD1' => { FIRSTNAME => 'Joe', LASTNAME => 'Smith' } } --- end contents --- Unfortunately, when I try to use "eval" to pull this hash variable construct into a second running process: --- begin contents --- sub retrieve_fields { my ( $file )=@_; my %fields; open(FILE, $file) { local $/; eval ; } return %fields; } --- end contents --- When I run the second program, perl dies on the "eval" line with this error: Variable "$fields" is not imported at (eval 125)[testprog.pl:33] line 1, chunk 1. The odd thing is if the Data::Dump file is changed to "%fields = ( ... )" then the "eval" works!?!? I've found some notes about using "our" and "use vars qw(...)". Anyone else have any suggestions? Dan -- "Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) ** *** ***** ******* *********** ************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Wed Aug 6 15:22:03 2008 From: jay at jays.net (Jay Hannah) Date: Wed, 6 Aug 2008 17:22:03 -0500 Subject: [Omaha.pm] Pulling in a hash via "exec"...FAIL In-Reply-To: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> References: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> Message-ID: <880B65DE-B3BB-475F-82E7-CDFD8CF6752C@jays.net> On Aug 6, 2008, at 5:08 PM, Dan Linder wrote: > I've got one program that generates a hash and then uses Data::Dump > to write this structure to a text file: > printf FILE Data::Dumper->Dump(\%fields],['fields']); Data::Dump isn't meant to be used like that. Use Storable instead: http://search.cpan.org/~ams/Storable-2.18/Storable.pm#EXAMPLES Much easier to use, and it works. :) j From dan at linder.org Wed Aug 6 18:03:16 2008 From: dan at linder.org (Dan Linder) Date: Wed, 6 Aug 2008 20:03:16 -0500 Subject: [Omaha.pm] Pulling in a hash via "exec"...FAIL In-Reply-To: <880B65DE-B3BB-475F-82E7-CDFD8CF6752C@jays.net> References: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> <880B65DE-B3BB-475F-82E7-CDFD8CF6752C@jays.net> Message-ID: <3e2be50808061803x6d1a11cidffeb17fdab9bf58@mail.gmail.com> On Aug 6, 2008, at 5:08 PM, Dan Linder wrote: > I've got one program that generates a hash and then uses Data::Dump to > write this structure to a text file: > printf FILE Data::Dumper->Dump(\%fields],['fields']); > On Wed, Aug 6, 2008 at 5:22 PM, Jay Hannah wrote: > Data::Dump isn't meant to be used like that. Use Storable instead: > http://search.cpan.org/~ams/Storable-2.18/Storable.pm#EXAMPLES > Much easier to use, and it works. :) > When I'm able to re-write the entire system I'll look at that. :-) For now I'm saddled with making the "eval" work ... unless I can figure out the magic of the "use vars" piece I'll have to manually touch up the first line of the output file. Thanks, Dan -- "Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) ** *** ***** ******* *********** ************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Wed Aug 6 18:37:50 2008 From: jay at jays.net (Jay Hannah) Date: Wed, 6 Aug 2008 20:37:50 -0500 Subject: [Omaha.pm] Pulling in a hash via "exec"...FAIL In-Reply-To: <3e2be50808061803x6d1a11cidffeb17fdab9bf58@mail.gmail.com> References: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> <880B65DE-B3BB-475F-82E7-CDFD8CF6752C@jays.net> <3e2be50808061803x6d1a11cidffeb17fdab9bf58@mail.gmail.com> Message-ID: <7207CE72-3561-47BC-909B-69B793CC7431@jays.net> On Aug 6, 2008, at 8:03 PM, Dan Linder wrote: > When I'm able to re-write the entire system I'll look at that. :-) "The entire system?" Here's my Storable version of what you posted to the list today: $ cat j.pl use Storable; my $fields = { 'FIELD1' => { FIRSTNAME => 'Joe', LASTNAME => 'Smith' } }; # Write to disk: store $fields, 'myfile.txt'; # Destroy memory version: undef $fields; # Restore from disk: $fields = retrieve('myfile.txt'); # Show that it worked: printf("%s %s\n", $fields->{FIELD1}->{FIRSTNAME}, $fields->{FIELD1}-> {LASTNAME}); $ perl j.pl Joe Smith All done...? j From jay at jays.net Wed Aug 6 18:47:44 2008 From: jay at jays.net (Jay Hannah) Date: Wed, 6 Aug 2008 20:47:44 -0500 Subject: [Omaha.pm] Pulling in a hash via "exec"...FAIL In-Reply-To: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> References: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> Message-ID: On Aug 6, 2008, at 5:08 PM, Dan Linder wrote: > sub retrieve_fields { > my ( $file )=@_; > my %fields; > open(FILE, $file) > { > local $/; > eval ; > } > return %fields; > } Have you tried this instead? sub retrieve_fields { my ( $file )=@_; my $fields; open(FILE, $file) { local $/; eval ; } return $fields; } HTH, j From dan at linder.org Thu Aug 7 06:37:29 2008 From: dan at linder.org (Dan Linder) Date: Thu, 7 Aug 2008 08:37:29 -0500 Subject: [Omaha.pm] Pulling in a hash via "exec"...FAIL In-Reply-To: References: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> Message-ID: <3e2be50808070637x60d6784dha3a79a1a1a27fa76@mail.gmail.com> On Wed, Aug 6, 2008 at 8:47 PM, Jay Hannah wrote: > Have you tried this instead? > sub retrieve_fields { > my ( $file )=@_; > my *$fields*; > open(FILE, $file) > { > local $/; > eval ; > } > return *$fields*; > } > I thought of that but I couldn't find an comments regarding the differences caused by changing the hash (%fields) to a straight variable ($fields). I know Perl doesn't do strict casting of variables, but this still looked odd to me. I'll give it a shot and see - the main program the retrieve_fields() subroutine resides in is used by a number of other collection routines and I don't want to break things too badly when adding my new section. (Sadly we don't have a test harness setup _yet_ so I don't have a baseline to work from...) Dan -- "Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) ** *** ***** ******* *********** ************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Thu Aug 7 07:50:36 2008 From: jay at jays.net (Jay Hannah) Date: Thu, 07 Aug 2008 09:50:36 -0500 Subject: [Omaha.pm] Pulling in a hash via "exec"...FAIL In-Reply-To: <3e2be50808070637x60d6784dha3a79a1a1a27fa76@mail.gmail.com> References: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> <3e2be50808070637x60d6784dha3a79a1a1a27fa76@mail.gmail.com> Message-ID: <489B0BBC.4070905@jays.net> Dan Linder wrote: > I thought of that but I couldn't find an comments regarding the differences > caused by changing the hash (%fields) to a straight variable ($fields). I > know Perl doesn't do strict casting of variables, but this still looked odd > to me. > -ponder- When you eval this $fields = { 'FIELD1' => { FIRSTNAME => 'Joe', LASTNAME => 'Smith' } $fields is a hash reference. But in your first post you were scoping and returning %fields, which is a hash. Hence your version was scoping and returning a hash which had absolutely nothing to do with what your were eval'ing. My change was scoping a scalar $fields, which the eval turns into a hash reference, and returns that. I assume this is what you meant to do. You might want to stick these in the top of your program: use strict; use warnings; use diagnostics; Those should help you see typos in your code... HTH, j (I still think eval is evil and you should use Storable. $0.02 -grin-) From dan at linder.org Thu Aug 7 08:09:32 2008 From: dan at linder.org (Dan Linder) Date: Thu, 7 Aug 2008 10:09:32 -0500 Subject: [Omaha.pm] Pulling in a hash via "exec"...FAIL In-Reply-To: <489B0BBC.4070905@jays.net> References: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> <3e2be50808070637x60d6784dha3a79a1a1a27fa76@mail.gmail.com> <489B0BBC.4070905@jays.net> Message-ID: <3e2be50808070809n2d268d52p2ce6897275111891@mail.gmail.com> Dan Linder wrote: > I thought of that but I couldn't find an comments regarding the differences >> caused by changing the hash (%fields) to a straight variable ($fields). I >> know Perl doesn't do strict casting of variables, but this still looked >> odd >> to me. >> > On Thu, Aug 7, 2008 at 9:50 AM, Jay Hannah wrote: > -ponder- When you eval this $fields = { > 'FIELD1' => { > FIRSTNAME => 'Joe', > LASTNAME => 'Smith' > } > > $fields is a hash reference. But in your first post you were scoping and > returning %fields, which is a hash. Hence your version was scoping and > returning a hash which had absolutely nothing to do with what your were > eval'ing. > > My change was scoping a scalar $fields, which the eval turns into a hash > reference, and returns that. I assume this is what you meant to do. The code I'm working on has had an unknown number of programmers over the last five years (most field engineers who hacked the code and submitted an enhancment, not necessiaraly any full-time programmers) so some of the code in it was probably put in and left there because it worked at the time and the permissiveness of Perl allowed for the abuse of variable type casting. :-) I need to gather a few more customer generated files to test, but I think changing to the scalar $fields is probably the correct answer. > You might want to stick these in the top of your program: > use strict; > use warnings; > use diagnostics; Yes, wonderful additions - unfortunatly I know that Perl will not execute this piece of code due to failures the "use strict" finds so working through them is probably the best solution. (And if not, I can always wrapper portions of code I can't fix with "no use strict"...sigh) (I still think eval is evil and you should use Storable. $0.02 -grin-) Hmmm, this must be a pretty evil program by your measure - it uses eval quite a bit. :-) Storable looks like a good solution, but the saved files need to be human readable like the Data::Dump output - I searched for a flag in the Storable perldoc but couldn't find one. (And I don't think that is the intention of Storable anyway - just provide the ability to store a MACHINE readable variable not HUMAN readable...) Dan -- "Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) ** *** ***** ******* *********** ************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Thu Aug 7 09:43:10 2008 From: jay at jays.net (Jay Hannah) Date: Thu, 07 Aug 2008 11:43:10 -0500 Subject: [Omaha.pm] regex's on steroids Message-ID: <489B261E.9030705@jays.net> Wow. Chris is a Perl regex genius: http://lists.open-bio.org/pipermail/bioperl-l/2008-August/028094.html I whip out the occasional zero-width negative look-behind assertion, but apparently Chris and 'Mastering Regular Expressions' know a lot more than I do. :) j From jay at jays.net Thu Aug 7 09:55:44 2008 From: jay at jays.net (Jay Hannah) Date: Thu, 07 Aug 2008 11:55:44 -0500 Subject: [Omaha.pm] Pulling in a hash via "exec"...FAIL In-Reply-To: <3e2be50808070809n2d268d52p2ce6897275111891@mail.gmail.com> References: <3e2be50808061508x68b59c87u9ea4716e347ec474@mail.gmail.com> <3e2be50808070637x60d6784dha3a79a1a1a27fa76@mail.gmail.com> <489B0BBC.4070905@jays.net> <3e2be50808070809n2d268d52p2ce6897275111891@mail.gmail.com> Message-ID: <489B2910.5000809@jays.net> Dan Linder wrote: > The code I'm working on has had an unknown number of programmers over the > last five years (most field engineers who hacked the code and submitted an > enhancment, not necessiaraly any full-time programmers) so some of the code > in it was probably put in and left there because it worked at the time and > the permissiveness of Perl allowed for the abuse of variable type casting. > :-) > Damn you, perl. Why do you give us so much rope when we're hell bent on hanging ourselves? :) > Yes, wonderful additions - unfortunatly I know that Perl will not execute > this piece of code due to failures the "use strict" finds so working through > them is probably the best solution. (And if not, I can always wrapper > portions of code I can't fix with "no use strict"...sigh) > Perhaps you can delete the stuff that use strict; bitches about? At least the scoping errors? Making the source a touch more readable? Care to post it on http://pastebin.com/ (or other) so we can see? > Hmmm, this must be a pretty evil program by your measure - it uses eval > quite a bit. :-) > Yikes. IMHO anyone who uses eval is honor-bound to support that code for life. They are not allowed to quit that job, or die. Eval is fine when I write it, or when you wrote it AND support it, but it's evil incarnate when you write it and I have to support it... > Storable looks like a good solution, but the saved files need to be human > readable like the Data::Dump output - I searched for a flag in the Storable > perldoc but couldn't find one. (And I don't think that is the intention of > Storable anyway - just provide the ability to store a MACHINE readable > variable not HUMAN readable...) > Ya. Agreed. So two files? The humans can read the dead-end .txt files if they want to, but the machine always restores the .storable file? store $fields, 'myfile.storable'; open(OUT, ">myfile.txt"); print OUT Data::Dumper->Dump( $fields ); Good luck! Sounds like a fun week! :) j From cjfields at illinois.edu Thu Aug 7 10:39:45 2008 From: cjfields at illinois.edu (Chris Fields) Date: Thu, 7 Aug 2008 12:39:45 -0500 Subject: [Omaha.pm] regex's on steroids In-Reply-To: <489B261E.9030705@jays.net> References: <489B261E.9030705@jays.net> Message-ID: <2F1DDBEA-E3DA-443E-B3EE-60796ED925B9@illinois.edu> On Aug 7, 2008, at 11:43 AM, Jay Hannah wrote: > Wow. Chris is a Perl regex genius: > > http://lists.open-bio.org/pipermail/bioperl-l/2008-August/028094.html > > I whip out the occasional zero-width negative look-behind assertion, > but apparently Chris and 'Mastering Regular Expressions' know a lot > more than I do. :) > > j Wait til p6 regexex/grammars! -c From dan at linder.org Thu Aug 7 13:51:49 2008 From: dan at linder.org (Dan Linder) Date: Thu, 7 Aug 2008 15:51:49 -0500 Subject: [Omaha.pm] regex's on steroids In-Reply-To: <489B261E.9030705@jays.net> References: <489B261E.9030705@jays.net> Message-ID: <3e2be50808071351n20c52e0k7a07664084133c38@mail.gmail.com> On Thu, Aug 7, 2008 at 11:43 AM, Jay Hannah wrote: > Wow. Chris is a Perl regex genius: > http://lists.open-bio.org/pipermail/bioperl-l/2008-August/028094.html > I whip out the occasional zero-width negative look-behind assertion, but > apparently Chris and 'Mastering Regular Expressions' know a lot more than I > do. :) > I think a little spring in my head just went *sproing*... Wow, add complex regexp to the list of things that the original programmer has to support after he dies... (or at least document very VERY well!) Dan -- "Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) ** *** ***** ******* *********** ************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Thu Aug 7 18:33:14 2008 From: jay at jays.net (Jay Hannah) Date: Thu, 7 Aug 2008 20:33:14 -0500 Subject: [Omaha.pm] Fwd: BarCamp Omaha just 8 days away! References: <1b5ac9dc0808071523g2f53e181y34dc307c1505ed5e@mail.gmail.com> Message-ID: <22865ED9-8806-426F-BA74-10C398C0A35E@jays.net> Perl Mongers, represent! :) I plan on being there for large blocks of time. j From: "Matt Secoske" Date: August 7, 2008 5:23:24 PM CDT To: "Matt Secoske" Subject: BarCamp Omaha just 8 days away! Hello, you are receiving this email because you have registered for BarCamp Omaha, or because you have shown interest by signing up for one of our various mailing lists. We are only 8 days away from the first BarCamp in Omaha, and we are expecting a great turnout! For those of you who haven't registered, here is the link: http:// barcampomaha.org/register/?event_id=1 All of this information is also available at http://barcampomaha.org Dates: August 15th - 17th Location: 8585 N. 96th Street Omaha, NE 68116 map at: http://barcampomaha.org/2008/08/05/frostacres-how-to-get-there/ Rough Schedule: (full schedule at http://barcampomaha.org/ 2008/08/04/the-schedule/) - Friday night social - Saturday sessions, breakfast lunch and dinner provided - Sunday morning brunch, more sessions until we are done Camping will be available onsite. 100% Free... we have sponsors covering the food, location, etc If you have talks you want to give, you can let us know by going to http://barcamp.org/BarCampOmaha Again, all of the information is available at http:// barcampomaha.org, register at http://barcampomaha.org/register/? event_id=1. Pass this on to anyone else you think would be interested!!! Hope to see you there! -- Matt Secoske From jay at jays.net Sun Aug 10 17:43:51 2008 From: jay at jays.net (Jay Hannah) Date: Sun, 10 Aug 2008 19:43:51 -0500 Subject: [Omaha.pm] Fwd: [odynug] August 12: Git by Sam Tesla References: <34c74d710808101737k62104d9dl2e595d9be4369791@mail.gmail.com> Message-ID: Our next meeting. Come on down! Omaha Perl Mongers http://omaha.pm.org And don't forget Bar Camp Omaha! http://barcampomaha.org/ Aug 15-17 j Begin forwarded message: > From: "Blaine Buxton" > Date: August 10, 2008 7:37:32 PM CDT > To: odynug > Subject: [odynug] August 12: Git by Sam Tesla > Reply-To: odynug at googlegroups.com > > Remember the good ole days when all you have to worry about was > CVS? Remember all the lost data and cursing at it? Subversion came > along and made us a bit happier, but again, it has its warts as > well. Could git be the answer to where CVS failed? Certainly, it > brings a lot to the table and nice features. Sam will show us why > Git is important, how it will never forget, and how it keeps tracks > without a central repository. > > Sam Tesla is going to go into depth of Git and let us know the ins > and outs. This should be one hell of a talk and not to be missed. > > Free pizza and new ideas will be served. Come one, come all! Here's > the specifics: > > http://odynug.kicks-ass.org > > Meeting location is UNO's Peter Kiewit Institute (PKI) building > 1110 South 67th Street > Omaha, NEAugust 12, 7pm-9pm > -- > Blaine Buxton > Sorcerer Of Digital Construction > http://blog.blainebuxton.com From jhannah at omnihotels.com Thu Aug 14 06:20:14 2008 From: jhannah at omnihotels.com (Jay Hannah) Date: Thu, 14 Aug 2008 08:20:14 -0500 Subject: [Omaha.pm] strange file exists behavior In-Reply-To: <396CEDAA86B38646ACE2FEAA22C3FBF1AFDA7A@l3exchange.omnihotels.net> Message-ID: I don?t think the file test operators do globbing. You can use glob() instead if you want. if (! glob(?$target_path/$filename")) { next; } perldoc ?f glob HTH, j On 8/14/08 7:54 AM, "Sean Baker" wrote: > Does anyone have any clue why my ?-e? check is saying file does not exist and > dropping me into the ?next;? statement? It doesn?t like asterisks? It works > fine when I use the entire file name. > > > main::(usw_response_by_min.pl:47): `scp lb1:$source_path/$filename > $target_path`; > DB<3> n > main::(usw_response_by_min.pl:48): if (! -e "$target_path/$filename") > { > DB<3> n > main::(usw_response_by_min.pl:49): next; > DB<3> p "$target_path/$filename" > /datamining/usw_log/ban*trans-20080813* > > > pbaker at omares-etl:/datamining/usw_log> ls > /datamining/usw_log/ban*trans-20080813* > /datamining/usw_log/banana_slicer.pl-trans-20080813.gz > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Thu Aug 14 07:02:16 2008 From: jay at jays.net (Jay Hannah) Date: Thu, 14 Aug 2008 09:02:16 -0500 Subject: [Omaha.pm] Using -> inside double quotes Message-ID: Funny how you can use -> inside double quotes to get at a hashref value, but you can't use it to invoke an object method. $ cat j2.pl package Jay; sub new { bless {} } sub lastname { "Hannah" } package main; my $href = { 7 => 'seven' }; my $jay = Jay->new(); print "$href->{7} $jay->lastname\n"; $ perl j2.pl seven Jay=HASH(0x8170b44)->lastname I guess that confusion is what taught me, years ago, to never use -> inside double quotes. Until today, when I hit someone's code doing it. Huh. I'm still learning perl5. :) j From jhannah at omnihotels.com Fri Aug 15 09:09:57 2008 From: jhannah at omnihotels.com (Jay Hannah) Date: Fri, 15 Aug 2008 11:09:57 -0500 Subject: [Omaha.pm] PerlNET - ActiveState Perl in Microsoft .NET References: Message-ID: <396CEDAA86B38646ACE2FEAA22C3FBF111DCB7@l3exchange.omnihotels.net> Wow. Here's the first time I've seen PerlNET in the wild... This is one of our vendors using CPAN's Crypt::Tea inside ASP.NET via PerlNET since they can't find a compatible TEA (Tiny Encryption Algorithm) implementation in Widowsland. (Until now. -grin-) j <%@ Page Language="perl" debug="true"%> -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Fri Aug 15 11:19:14 2008 From: jay at jays.net (Jay Hannah) Date: Fri, 15 Aug 2008 13:19:14 -0500 Subject: [Omaha.pm] Evolution of a POE server Message-ID: <48A5C8A2.2090700@jays.net> An awesome POE tutorial I hadn't seen before today: http://poe.perl.org/?Evolution_of_a_POE_Server We use POE for Linux process queuing / management and writing custom TCP/IP services. j From jay at jays.net Sat Aug 16 13:44:52 2008 From: jay at jays.net (Jay Hannah) Date: Sat, 16 Aug 2008 13:44:52 -0700 (PDT) Subject: [Omaha.pm] Catalyst - database access syntax Message-ID: <2eb490d7-4f4d-45b6-aaf9-a48713cc3a05@m36g2000hse.googlegroups.com> For the programmers out there... Ryan's talk covered database syntax in ColdFusion, which made me regret that I didn't demo that too. Here's the default database manipulation syntax in Catalyst + Template Toolkit, if you're interested. To add a list of Twitter accounts to the little app I demo'd you can throw this into your HTML (the tags are Template Toolkit syntax): ------------------ [% FOREACH followers IN c.model('BarCampOmaha::Model::DB::Followers').all %] [% END %]
Twitter IDName
[% followers.twitter_id %] [% followers.name %] delete
------------------ This reads out of a little sqlite database on my laptop, but could be any data source. Now we need two new Actions: a delete and an add. So we throw this into Controller/Twitter ------------ sub add : Path("add") { my ( $self, $c ) = @_; $c->model('BarCampOmaha::Model::DB::Followers')->create({ twitter_id => $c->req->param('twitter_id'), name => $c->req->param('name'), }); $c->res->redirect('/barcampomaha/homepage'); } sub delete : Path("delete") { my ( $self, $c ) = @_; $c->model('BarCampOmaha::Model::DB::Followers')->search({ twitter_id => $c->req->param('twitter_id'), })->delete_all; $c->res->redirect('/barcampomaha/homepage'); } ------------ All done. Cheers, j Omaha Perl Mongers: http://omaha.pm.org From jay at jays.net Tue Aug 19 21:18:05 2008 From: jay at jays.net (Jay Hannah) Date: Tue, 19 Aug 2008 23:18:05 -0500 Subject: [Omaha.pm] for (@row) Message-ID: Less code is easier to read? j BEFORE: for (0 .. @row - 1) { $row[$_] =~ s/[^ -~]//g; $row[$_] =~ s/\s+$//; $row[$_] = uc($row[$_]); } AFTER: for (@row) { s/[^ -~]//g; s/\s+$//; tr/a-z/A-Z/; } From dan at linder.org Wed Aug 20 09:35:25 2008 From: dan at linder.org (Dan Linder) Date: Wed, 20 Aug 2008 11:35:25 -0500 Subject: [Omaha.pm] for (@row) In-Reply-To: References: Message-ID: <3e2be50808200935g64e9ddf0wf103486398d41490@mail.gmail.com> On Tue, Aug 19, 2008 at 11:18 PM, Jay Hannah wrote: > Less code is easier to read? I agree, but whenever I glance at code I'm always having to re-convince myself that the "for (@array) {...}" loop does actually allow you to update the @array in place. To cover for people like me, make this your after: AFTER: # In-place updates to each line of @row. for (@row) { s/[^ -~]//g; s/\s+$//; tr/a-z/A-Z/; } -- "Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) ** *** ***** ******* *********** ************* From jay at jays.net Wed Aug 20 13:54:55 2008 From: jay at jays.net (Jay Hannah) Date: Wed, 20 Aug 2008 15:54:55 -0500 Subject: [Omaha.pm] for (@row) In-Reply-To: <3e2be50808200935g64e9ddf0wf103486398d41490@mail.gmail.com> References: <3e2be50808200935g64e9ddf0wf103486398d41490@mail.gmail.com> Message-ID: On Aug 20, 2008, at 11:35 AM, Dan Linder wrote: > AFTER: > # In-place updates to each line of @row. > for (@row) { > s/[^ -~]//g; > s/\s+$//; > tr/a-z/A-Z/; > } How about this: # mwooo-hahahha Dan. I'm doing it again!! -laugh- for(@row){s/[^ -~]//g;s/\s+$//;tr/a-z/A-Z/} Or common_in_place_updates(\@row); :) j From jay at jays.net Wed Aug 20 19:20:40 2008 From: jay at jays.net (Jay Hannah) Date: Wed, 20 Aug 2008 21:20:40 -0500 Subject: [Omaha.pm] 17 Perl web frameworks Message-ID: <4246BAA5-6B6D-4A80-B1D2-634BEBCC40CD@jays.net> I'm a full blown addict of Catalyst now, but there's 16 other Perl ones you could use instead: http://www.perlfoundation.org/perl5/index.cgi?web_frameworks TIMTOWTDI! :) j From tedkat at gmail.com Thu Aug 21 13:27:11 2008 From: tedkat at gmail.com (Theodore Katseres) Date: Thu, 21 Aug 2008 15:27:11 -0500 Subject: [Omaha.pm] 17 Perl web frameworks In-Reply-To: <4246BAA5-6B6D-4A80-B1D2-634BEBCC40CD@jays.net> References: <4246BAA5-6B6D-4A80-B1D2-634BEBCC40CD@jays.net> Message-ID: On Wed, Aug 20, 2008 at 9:20 PM, Jay Hannah wrote: > I'm a full blown addict of Catalyst now, but there's 16 other Perl ones you > could use instead: Do you use the Chained attribute? I'm still trying to wrap my head around it. -- Ted Katseres ||=O=|| From jay at jays.net Thu Aug 21 14:08:19 2008 From: jay at jays.net (Jay Hannah) Date: Thu, 21 Aug 2008 16:08:19 -0500 Subject: [Omaha.pm] 17 Perl web frameworks In-Reply-To: References: <4246BAA5-6B6D-4A80-B1D2-634BEBCC40CD@jays.net> Message-ID: <48ADD943.5020701@jays.net> Theodore Katseres wrote: > Do you use the Chained attribute? I'm still trying to wrap my head around it. > Nope. It's all the rage in IRC (irc.perl.org #catalyst) but I still don't get it. And apparently don't need it. (Yet?) :) j From dan at linder.org Fri Aug 22 07:46:05 2008 From: dan at linder.org (Dan Linder) Date: Fri, 22 Aug 2008 09:46:05 -0500 Subject: [Omaha.pm] CSV and core modules. Message-ID: <3e2be50808220746h4e6528bbla69adf9981620d2c@mail.gmail.com> Hello Omaha Perl Mongers: I'm working on a project that will pull in data from CSV files. The old version of the program does all the CSV processing itself (i.e. split(/,/, $line). While this works, there are a few text fields that could potentially contain commas themselves that would break this horribly. While the though occurred to me to try and come up with a new RegExp for the find to ignore commas between quote (") characters, I thought I'd ask the wisdom of the list to see if there was a CSV perl module I'm missing? I'd really like one that's included as part of the Perl core distribution (5.8 and higher). Did I miss this module? If that's not an option, I've played with the Text::CSV_XS module and it seems to work well. Any other favorite CSV modules people use? Dan -- "Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) ** *** ***** ******* *********** ************* From stpierre at NebrWesleyan.edu Fri Aug 22 07:53:43 2008 From: stpierre at NebrWesleyan.edu (Chris St. Pierre) Date: Fri, 22 Aug 2008 09:53:43 -0500 (CDT) Subject: [Omaha.pm] CSV and core modules. In-Reply-To: <3e2be50808220746h4e6528bbla69adf9981620d2c@mail.gmail.com> References: <3e2be50808220746h4e6528bbla69adf9981620d2c@mail.gmail.com> Message-ID: Text::ParseWords might work for you. Chris St. Pierre Unix Systems Administrator Nebraska Wesleyan University On Fri, 22 Aug 2008, Dan Linder wrote: > Hello Omaha Perl Mongers: > > I'm working on a project that will pull in data from CSV files. The > old version of the program does all the CSV processing itself (i.e. > split(/,/, $line). While this works, there are a few text fields that > could potentially contain commas themselves that would break this > horribly. While the though occurred to me to try and come up with a > new RegExp for the find to ignore commas between quote (") characters, > I thought I'd ask the wisdom of the list to see if there was a CSV > perl module I'm missing? > > I'd really like one that's included as part of the Perl core > distribution (5.8 and higher). Did I miss this module? > > If that's not an option, I've played with the Text::CSV_XS module and > it seems to work well. Any other favorite CSV modules people use? > > Dan > > -- > "Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from > the Satires of Juvenal > "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) > ** *** ***** ******* *********** ************* > _______________________________________________ > Omaha-pm mailing list > Omaha-pm at pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm > From jay at jays.net Fri Aug 22 07:54:08 2008 From: jay at jays.net (Jay Hannah) Date: Fri, 22 Aug 2008 09:54:08 -0500 Subject: [Omaha.pm] CSV and core modules. In-Reply-To: <3e2be50808220746h4e6528bbla69adf9981620d2c@mail.gmail.com> References: <3e2be50808220746h4e6528bbla69adf9981620d2c@mail.gmail.com> Message-ID: <48AED310.9050103@jays.net> Dan Linder wrote: > I'm working on a project that will pull in data from CSV files. The > old version of the program does all the CSV processing itself (i.e. > split(/,/, $line). search.cpan.org for "csv" has lots of hits. :) I've used Text::CSV in the past. To quote Text::CSV::Simple http://search.cpan.org/~tmtm/Text-CSV-Simple-1.00/lib/Text/CSV/Simple.pm "Parsing CSV files is nasty. It seems so simple, but it usually isn't. Thankfully Text::CSV_XS takes care of most of that nastiness for us. Like many modules which have to deal with all manner of nastiness and edge cases, however, it can be clumsy to work with in the simple case. Thus this module." So perl -MCPAN -e 'install Text::CSV::Simple' ? HTH, j From jay at jays.net Mon Aug 25 13:27:52 2008 From: jay at jays.net (Jay Hannah) Date: Mon, 25 Aug 2008 15:27:52 -0500 Subject: [Omaha.pm] Redhat perl what a tragedy Message-ID: <48B315C8.2050602@jays.net> http://blog.vipul.net/2008/08/24/redhat-perl-what-a-tragedy/ "...and we were processing data 100x to 1000x faster!" **My quick tests on my Ubuntu's and SuSE's is showing the program running in < 0.2s. So apparently I'm not effected. :) j From dan at linder.org Mon Aug 25 14:52:01 2008 From: dan at linder.org (Dan Linder) Date: Mon, 25 Aug 2008 16:52:01 -0500 Subject: [Omaha.pm] CGI::Ajax and saving state... Message-ID: <3e2be50808251452ub5b86f0t7226c7688d5b4632@mail.gmail.com> I'm playing with CGI::Ajax as part of the interface. What I'm struggling with passing state between subsequent calls to the Perl function registered to the AJAX javascript. Before I get too deep into specifics, are there any CGI::Ajax users out there that might want to point me in the right direction? Dan -- "Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) ** *** ***** ******* *********** ************* From jay at jays.net Mon Aug 25 14:57:57 2008 From: jay at jays.net (Jay Hannah) Date: Mon, 25 Aug 2008 16:57:57 -0500 Subject: [Omaha.pm] CGI::Ajax and saving state... In-Reply-To: <3e2be50808251452ub5b86f0t7226c7688d5b4632@mail.gmail.com> References: <3e2be50808251452ub5b86f0t7226c7688d5b4632@mail.gmail.com> Message-ID: <48B32AE5.8090603@jays.net> Dan Linder wrote: > Before I get too deep into specifics, are there any CGI::Ajax users > out there that might want to point me in the right direction? > Not I, sorry. But perhaps I could tempt you with this Catalyst demo? http://www.perl.com/lpt/a/930 "Sample Application: MiniMojo, an Ajax-Based Wiki in 30 Lines of Written Code" :) j From rob.townley at gmail.com Mon Aug 25 20:18:35 2008 From: rob.townley at gmail.com (Rob Townley) Date: Mon, 25 Aug 2008 22:18:35 -0500 Subject: [Omaha.pm] Redhat perl what a tragedy In-Reply-To: <48B315C8.2050602@jays.net> References: <48B315C8.2050602@jays.net> Message-ID: <7e84ed60808252018x34c25540w7ee257346cb4fb84@mail.gmail.com> i wonder if it boils down to a version of gcc.... optimization settings.... On Mon, Aug 25, 2008 at 3:27 PM, Jay Hannah wrote: > http://blog.vipul.net/2008/08/24/redhat-perl-what-a-tragedy/ > > "...and we were processing data 100x to 1000x faster!" > > **My quick tests on my Ubuntu's and SuSE's is showing the program running > in < 0.2s. So apparently I'm not effected. :) > > j > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm at pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at petdance.com Mon Aug 25 20:21:30 2008 From: andy at petdance.com (Andy Lester) Date: Mon, 25 Aug 2008 22:21:30 -0500 Subject: [Omaha.pm] Redhat perl what a tragedy In-Reply-To: <7e84ed60808252018x34c25540w7ee257346cb4fb84@mail.gmail.com> References: <48B315C8.2050602@jays.net> <7e84ed60808252018x34c25540w7ee257346cb4fb84@mail.gmail.com> Message-ID: <3861DCFE-556B-4608-9923-F0D8892C87CB@petdance.com> On Aug 25, 2008, at 10:18 PM, Rob Townley wrote: > i wonder if it boils down to a version of gcc.... optimization > settings.... No, Redhat had a custom patch on their Perl package that causes the problem. Redhat has said it's their problem. http://perlbuzz.com/2008/08/red-hats-patch-slows-down-overloading-in-perl.html xoxo, Andy -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From dan at linder.org Tue Aug 26 07:11:48 2008 From: dan at linder.org (Dan Linder) Date: Tue, 26 Aug 2008 09:11:48 -0500 Subject: [Omaha.pm] CGI::Ajax and saving state... In-Reply-To: <48B32AE5.8090603@jays.net> References: <3e2be50808251452ub5b86f0t7226c7688d5b4632@mail.gmail.com> <48B32AE5.8090603@jays.net> Message-ID: <3e2be50808260711o456725c5ja022c59e826dbb7f@mail.gmail.com> On Mon, Aug 25, 2008 at 4:57 PM, Jay Hannah wrote: > Not I, sorry. But perhaps I could tempt you with this Catalyst demo? > http://www.perl.com/lpt/a/930 > "Sample Application: MiniMojo, an Ajax-Based Wiki in 30 Lines of Written > Code" Thanks, the Catalyst framework looks promising, but I have to take baby-steps with this project. :-) Didn't someone give a talk on Catalyst at a recent OLUG or PM meeting? If so, are there any slides and/or notes that I could reference - might pass this by my team. I'll keep working with CGI::Ajax and if I make up any eye-catching demos I'll share them. Dan -- "Quis custodiet ipsos custodes?" (Who can watch the watchmen?) -- from the Satires of Juvenal "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) ** *** ***** ******* *********** ************* From jay at jays.net Tue Aug 26 07:19:24 2008 From: jay at jays.net (Jay Hannah) Date: Tue, 26 Aug 2008 09:19:24 -0500 Subject: [Omaha.pm] CGI::Ajax and saving state... In-Reply-To: <3e2be50808260711o456725c5ja022c59e826dbb7f@mail.gmail.com> References: <3e2be50808251452ub5b86f0t7226c7688d5b4632@mail.gmail.com> <48B32AE5.8090603@jays.net> <3e2be50808260711o456725c5ja022c59e826dbb7f@mail.gmail.com> Message-ID: <8CF4D02C-E1D8-4C48-BE0A-5DED969ACC36@jays.net> On Aug 26, 2008, at 9:11 AM, Dan Linder wrote: > Thanks, the Catalyst framework looks promising, but I have to take > baby-steps with this project. :-) $ catalyst.pl ThisProject poof! You've got a working Catalyst application. How's that for baby steps? :) > Didn't someone give a talk on Catalyst at a recent OLUG or PM meeting? > If so, are there any slides and/or notes that I could reference - > might pass this by my team. I'm not aware of any other Catalyst evangelists in Omaha, so maybe it was me? I gave a 40 minute shpeel on Catalyst and Moose at Bar Camp a couple weekends ago. I can do a one hour Catalyst sales pitch at a Perl Monger / Omaha Dynamic Language Users group meeting if anyone wants to see it. > I'll keep working with CGI::Ajax and if I make up any eye-catching > demos I'll share them. Ya, I love demos! Let us know when it's ready and lets get together! :) j From jhannah at omnihotels.com Tue Aug 26 09:12:15 2008 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue, 26 Aug 2008 11:12:15 -0500 Subject: [Omaha.pm] Benchmark flakiness Message-ID: Weird... ----------- use Benchmark qw( :hireswallclock ); timethis(100000, ' for ($x=0; $x<=200; $x++) { sin($x/($x+2)); } '); ----------- On my Mac this takes 10 seconds and outputs this: timethis 100000: 9.88306 wallclock secs ( 9.80 usr + 0.02 sys = 9.82 CPU) @ 10183.30/s (n=100000) On my SuSE box it takes between 10 and 20 seconds and outputs this regardless of how long it really took: timethis 100000: 10.2632 wallclock secs ( 9.13 usr + 0.27 sys = 9.40 CPU) @ 10638.30/s (n=100000) So the reported wallclock is fine on my Mac (idle or under load) but lies on SuSE under load. It gets worse: ----------- use Benchmark qw( timethese cmpthese :hireswallclock ) ; $x = 3; $r = timethese( 10000000, { a => sub{$x*$x}, b => sub{$x**2}, } ); cmpthese $r; ------------ On my Mac this takes 22 seconds and outputs this: Benchmark: timing 10000000 iterations of a, b... a: 1.02988 wallclock secs ( 1.02 usr + -0.01 sys = 1.01 CPU) @ 9900990.10/s (n=10000000) b: 1.10844 wallclock secs ( 1.12 usr + -0.01 sys = 1.11 CPU) @ 9009009.01/s (n=10000000) Rate b a b 9009009/s -- -9% a 9900990/s 10% -- On SuSE it takes 30 seconds and outputs this: Benchmark: timing 10000000 iterations of a, b... a: 1.94711 wallclock secs ( 1.56 usr + 0.13 sys = 1.69 CPU) @ 5917159.76/s (n=10000000) b: 1.65905 wallclock secs ( 1.52 usr + 0.11 sys = 1.63 CPU) @ 6134969.33/s (n=10000000) Rate a b a 5917160/s -- -4% b 6134969/s 4% -- So in timethese() wallclock is entirely hosed... Bummer. Roll our own, I guess... -sigh- j -------------- next part -------------- An HTML attachment was scrubbed... URL: From jhannah at omnihotels.com Tue Aug 26 10:40:33 2008 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue, 26 Aug 2008 12:40:33 -0500 Subject: [Omaha.pm] Wow. The New York Times profiler. Message-ID: Wow. The New York Times profiler is way too cool and insanely easy to use. Question: I'm just loading a little Moose object and printing it. Why is it taking over a second?? Answer: Use the New York Times profiler: $ perl -d:NYTProf j.pl [123] Jay Hannah $ nytprof nytprof.out Result: http://jay.mammoth.org/tmp/nytprof/ Can you find the problem? -grin- Hint: In "Employee::string" at the top, click "string". There's my source code. See the problem? Cheers, j ( Note that you currently need the Google Code SVN version to see the code inside Moose objects. CPAN version is not yet sufficient. http://code.google.com/p/perl-devel-nytprof/source/checkout ) The source code: $ cat j.pl #!/usr/bin/perl use Employee; my $e = Employee->new(); $e->first_name("Jay"); $e->last_name("Hannah"); $e->employee_id(123); print $e->string, "\n"; Takes over a second to run: $ time perl j.pl [123] Jay Hannah real 0m1.256s user 0m0.233s sys 0m0.021s -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Tue Aug 26 15:06:00 2008 From: jay at jays.net (Jay Hannah) Date: Tue, 26 Aug 2008 17:06:00 -0500 Subject: [Omaha.pm] Fwd: Newsletter from O'Reilly UG Program, August 26 References: Message-ID: http://oreilly.com/emails/ug-newsletter-aug08.html - Why Corporates Hate Perl - The Mind of Damian Conway: Science, Computer Science, the Future of Perl 6, and Advice for Today's Aspiring Programmers Cheers, j From jay at jays.net Wed Aug 27 11:55:02 2008 From: jay at jays.net (Jay Hannah) Date: Wed, 27 Aug 2008 13:55:02 -0500 Subject: [Omaha.pm] $0 = "I am not running"; Message-ID: <045CC69C-4A88-473F-8AF5-D3F4B9CAE789@jays.net> Fascinating. When you set $0 inside a running Perl program, "ps w" and "ps -ef" and some others will report whatever you set. But "ps" won't change... j $ perl -e '$0 = "I am not running"; sleep 10' & $ ps PID TTY TIME CMD 11323 pts/0 00:00:00 bash 11631 pts/0 00:00:00 perl 11656 pts/0 00:00:00 ps $ ps w PID TTY STAT TIME COMMAND 11323 pts/0 S 0:00 -bash 11631 pts/0 S 0:00 I am not running 11657 pts/0 R+ 0:00 ps w From andy at petdance.com Wed Aug 27 11:58:52 2008 From: andy at petdance.com (Andy Lester) Date: Wed, 27 Aug 2008 13:58:52 -0500 Subject: [Omaha.pm] $0 = "I am not running"; In-Reply-To: <045CC69C-4A88-473F-8AF5-D3F4B9CAE789@jays.net> References: <045CC69C-4A88-473F-8AF5-D3F4B9CAE789@jays.net> Message-ID: On Aug 27, 2008, at 1:55 PM, Jay Hannah wrote: > Fascinating. When you set $0 inside a running Perl program, "ps w" > and "ps -ef" and some others will report whatever you set. But "ps" > won't change... It's all platform-dependent. From perldoc perlvar: $0 Contains the name of the program being executed. On some (read: not all) operating systems assigning to $0 modifies the argument area that the "ps" program sees. On some platforms you may have to use special "ps" options or a different "ps" to see the changes. Modifying the $0 is more useful as a way of indicating the current program state than it is for hiding the program you?re running. (Mnemonic: same as sh and ksh.) Note that there are platform specific limitations on the maximum length of $0. In the most extreme case it may be limited to the space occupied by the original $0. In some platforms there may be arbitrary amount of padding, for example space characters, after the modified name as shown by "ps". In some platforms this padding may extend all the way to the original length of the argument area, no matter what you do (this is the case for example with Linux 2.2). Note for BSD users: setting $0 does not completely remove "perl" from the ps(1) output. For example, setting $0 to "foobar" may result in "perl: foobar (perl)" (whether both the "perl: " prefix and the " (perl)" suffix are shown depends on your exact BSD variant and version). This is an operating system feature, Perl cannot help it. In multithreaded scripts Perl coordinates the threads so that any thread may modify its copy of the $0 and the change becomes visible to ps(1) (assuming the operating system plays along). Note that the view of $0 the other threads have will not change since they have their own copies of it. -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From jbisbee at gmail.com Thu Aug 28 04:04:29 2008 From: jbisbee at gmail.com (Jeff Bisbee) Date: Thu, 28 Aug 2008 07:04:29 -0400 Subject: [Omaha.pm] $0 = "I am not running"; In-Reply-To: <045CC69C-4A88-473F-8AF5-D3F4B9CAE789@jays.net> References: <045CC69C-4A88-473F-8AF5-D3F4B9CAE789@jays.net> Message-ID: There is no spoon :) On Wed, Aug 27, 2008 at 2:55 PM, Jay Hannah wrote: > Fascinating. When you set $0 inside a running Perl program, "ps w" and "ps > -ef" and some others will report whatever you set. But "ps" won't change... > > j > > > $ perl -e '$0 = "I am not running"; sleep 10' & > $ ps > PID TTY TIME CMD > 11323 pts/0 00:00:00 bash > 11631 pts/0 00:00:00 perl > 11656 pts/0 00:00:00 ps > $ ps w > PID TTY STAT TIME COMMAND > 11323 pts/0 S 0:00 -bash > 11631 pts/0 S 0:00 I am not running > 11657 pts/0 R+ 0:00 ps w > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm at pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm > -- Jeff Bisbee / jbisbee at gmail.com / jbisbee.multiply.com