From pbaker at omnihotels.com Mon Oct 3 06:43:36 2005 From: pbaker at omnihotels.com (Sean Baker) Date: Mon, 3 Oct 2005 08:43:36 -0500 Subject: [Omaha.pm] Ow!! || bit me Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B033D03AB@exchange2k3.omnihotels.net> In the context you're using it, it would never get set to 7, it would always be undef. -----Original Message----- From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf Of Jay Hannah Sent: Friday, September 30, 2005 3:42 PM To: Perl Mongers of Omaha, Nebraska USA Subject: Re: [Omaha.pm] Ow!! || bit me On Sep 30, 2005, at 2:38 PM, Kenneth Thompson wrote: > Wouldn't this work? > > $res->set_child_qty($cookie->{child_qty} || $q->param('child_qty') || > 0); > > Since it ignores the falses (0 and undef), it would fall through to the > last choice, which would be your default? As discussed: Yes, but it wouldn't Do The Right Thing (set_child_qty(0)) if $cookie->{child_qty} was 0 and $q->param('child_qty') was 7. It would set_child_qty(7). The Wrong Thing. -grin- j _______________________________________________ Omaha-pm mailing list Omaha-pm at pm.org http://mail.pm.org/mailman/listinfo/omaha-pm From jhannah at omnihotels.com Tue Oct 11 13:25:13 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue, 11 Oct 2005 15:25:13 -0500 Subject: [Omaha.pm] FW: Help Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACD3D@exchange2k3.omnihotels.net> -----Original Message----- At some point, can you show me how to fix this? couldn't load CGI::Session::Serialize::freezethaw: Can't locate FreezeThaw.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/Omni/MVC /usr/lib/perl5/5.8.7/i686-linux /usr/lib/perl5/5.8.7 /usr/local/lib/perl5/site_perl/5.8.7/i686-linux /usr/local/lib/perl5/site_perl/5.8.7 /usr/local/lib/perl5/site_perl /usr/lib/perl5/site_perl/Omni .) at /usr/local/lib/perl5/site_perl/5.8.7/CGI/Session/Serialize/freezethaw.pm line 6. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.8.7/CGI/Session/Serialize/freezethaw.pm line 6. Compilation failed in require at (eval 31) line 3. The module it's looking for is currently here (/usr/local/lib/perl5/site_perl/5.8.7/Data/Serializer/FreezeThaw.pm)... I'm not sure what to change to make it work (at least the correct way to change it). ------------------------- Hmmm... Well, a .pm file that lives here /usr/local/lib/perl5/site_perl/5.8.7/Data/Serializer/FreezeThaw.pm Would be namespace Data::Serializer::FreezeThaw So "Can't locate FreezeThaw" is an awfully strange error message. Where did freezethaw come from? Is it part of some other package or something you added? j From dan at linder.org Tue Oct 11 13:35:04 2005 From: dan at linder.org (Daniel Linder) Date: Tue, 11 Oct 2005 15:35:04 -0500 (CDT) Subject: [Omaha.pm] FW: Help In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B031ACD3D@exchange2k3.omnihotels.net> References: <29AB736ABCE5C745ABF9C93B02F2C27B031ACD3D@exchange2k3.omnihotels.net> Message-ID: <1406.68.13.86.85.1129062904.squirrel@mail.linder.org> On Tue, October 11, 2005 15:25, Jay Hannah wrote: > couldn't load CGI::Session::Serialize::freezethaw: Can't locate > FreezeThaw.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/Omni/MVC > /usr/local/lib/perl5/site_perl/5.8.7/CGI/Session/Serialize/freezethaw.pm > line 6. > BEGIN failed--compilation aborted at > /usr/local/lib/perl5/site_perl/5.8.7/CGI/Session/Serialize/freezethaw.pm > line 6. I noticed that the first mention of "FreezeThaw.pm" was in mixed case, but later the error says aborted at line 6 with "freezethaw.pm". I've never generated my own PM file, but could the mis-match on upper/lower case cause any problem? Dan - - - - "Wait for that wisest of all counselors, time." -- Pericles "I do not fear computer, I fear the lack of them." -- Isaac Asimov GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20051011/96a12359/attachment.html From Scott.L.Miller at hp.com Tue Oct 11 15:00:52 2005 From: Scott.L.Miller at hp.com (Miller, Scott L (Omaha Networks)) Date: Tue, 11 Oct 2005 17:00:52 -0500 Subject: [Omaha.pm] FW: Help Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E9AB@omaexc11.americas.cpqcorp.net> Yes, and so could an extra or missing 'r' on Serializer... ________________________________ From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf Of Daniel Linder Sent: Tuesday, October 11, 2005 3:35 PM To: Perl Mongers of Omaha, Nebraska USA Cc: omaha-pm at pm.org Subject: Re: [Omaha.pm] FW: Help On Tue, October 11, 2005 15:25, Jay Hannah wrote: > couldn't load CGI::Session::Serialize::freezethaw: Can't locate > FreezeThaw.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/Omni/MVC > /usr/local/lib/perl5/site_perl/5.8.7/CGI/Session/Serialize/freezethaw.pm > line 6. > BEGIN failed--compilation aborted at > /usr/local/lib/perl5/site_perl/5.8.7/CGI/Session/Serialize/freezethaw.pm > line 6. I noticed that the first mention of "FreezeThaw.pm" was in mixed case, but later the error says aborted at line 6 with "freezethaw.pm". I've never generated my own PM file, but could the mis-match on upper/lower case cause any problem? Dan - - - - "Wait for that wisest of all counselors, time." -- Pericles "I do not fear computer, I fear the lack of them." -- Isaac Asimov GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20051011/dab55826/attachment.html From jhannah at omnihotels.com Thu Oct 13 12:37:45 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Thu, 13 Oct 2005 14:37:45 -0500 Subject: [Omaha.pm] Test::More warning Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACD54@exchange2k3.omnihotels.net> Hey Kenn -- Don't know if you know this or not, but that # at the end of the test is complaining that you added 5 tests but only bumped the test count up 3. (v1.4 back on 8/17. Wow... has it been that long since we switched to Class::Date?) No biggie, just FYI. (Test::More, Class::Date rule!) j $ perl DateTime.t 1..53 ok 1 - If you explicity hand us undef we won't instantiate ok 2 - If you explicity hand us undef we won't instantiate -snip- ok 53 - Don't automatically add time to dates ok 54 - new() ok 55 - Don't automatically add time to dates # Looks like you planned 53 tests but ran 2 extra. $ From jay at jays.net Sat Oct 15 05:27:22 2005 From: jay at jays.net (Jay Hannah) Date: Sat, 15 Oct 2005 07:27:22 -0500 Subject: [Omaha.pm] XML::Parser test (install) failures Message-ID: So I was trying to run perl -MCPAN -e 'install XML::Parser' and when the tests ran it would throw this goo: Running make test make[1]: Entering directory `/tmp/.cpan/build/XML-Parser-2.34/Expat' make[1]: Leaving directory `/tmp/.cpan/build/XML-Parser-2.34/Expat' PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/astress.........Can't load '/tmp/.cpan/build/XML-Parser-2.34/blib/arch/auto/XML/Parser/Expat/ Expat.so' for module XML::Parser::Expat: /tmp/.cpan/build/XML-Parser-2.34/blib/arch/auto/XML/Parser/Expat/ Expat.so: failed to map segment from shared object: Operation not permitted at /usr/lib/perl5/5.8.6/i386-linux-thread-multi/DynaLoader.pm line 230. at /tmp/.cpan/build/XML-Parser-2.34/blib/lib/XML/Parser.pm line 14 Compilation failed in require at /tmp/.cpan/build/XML-Parser-2.34/blib/lib/XML/Parser.pm line 14. BEGIN failed--compilation aborted at /tmp/.cpan/build/XML-Parser-2.34/blib/lib/XML/Parser.pm line 18. Compilation failed in require at t/astress.t line 11. BEGIN failed--compilation aborted at t/astress.t line 11. t/astress.........dubious Test returned status 255 (wstat 65280, 0xff00) DIED. FAILED tests 1-27 Failed 27/27 tests, 0.00% okay Since the tests fail, the install would fail. Bummer. I am not a C programmer, so this stuff usually makes no sense to me at all. I googled around a bit and found that apparently this has something to do with the fact that my /tmp directory is mounted as noexec (/etc/fstab). So I switch CPAN/Config.pm to tell it to build everything in /root instead of /tmp (so it uses /root/.cpan instead of /tmp/.cpan). Voila, everything is peachy again. I don't understand dynamic linking libraries or any of that goo. Maybe I should learn C some day. I seem to need to know C for about 3 hours per year, usually when building stuff... Not really motivated to study C for 3 years just to save myself a few hours a year... :) Perl has made me lazzzzy... j From jay at jays.net Sat Oct 15 07:35:30 2005 From: jay at jays.net (Jay Hannah) Date: Sat, 15 Oct 2005 09:35:30 -0500 Subject: [Omaha.pm] Meeting: Thr Oct 20 @ 7pm. Free food! Message-ID: <09e14323e691ae1623ab502a592b6070@jays.net> Tweaked: http://omaha.pm.org/ Free food! Chad has offered to sponsor food at our meetings! Chad Hendren Paragon IT Professionals http://www.paragondm.com/ Kindly RSVP so I know how much food to order. If I don't get RSVPs or other food suggestions I'll assume our usual 3-4 attendees and have 3 large pizzas arrive @ 7pm. I'll bring plates, napkins, pop. (uhh... beer? -grin-) Topics: If no one has suggestions I'll wander around the following stuff I've been doing lately: - Show off my Google maps API thing: http://jays.net/google_maps/index2.html including my XML::Twig gizmo - I've taken up genealogy. This tool rules: http://www.pidcock.co.uk/gth/ - The Perl Monger business cards I slapped together: http://omaha.pm.org/kwiki/index.cgi?BusinessCards we should finalize, order them Or whatever. -grin- See you there! j From jay at jays.net Sat Oct 15 09:41:42 2005 From: jay at jays.net (Jay Hannah) Date: Sat, 15 Oct 2005 11:41:42 -0500 Subject: [Omaha.pm] [olug] Database export problem In-Reply-To: <20051010174842.37524.qmail@web33207.mail.mud.yahoo.com> References: <20051010174842.37524.qmail@web33207.mail.mud.yahoo.com> Message-ID: <48d1659e72db959d16a2461cea69d9f6@jays.net> On Oct 10, 2005, at 12:48 PM, Eric Lusk wrote: > Well, it's slow work but I'm getting there.... Found > out I can export PARTS of the database, but end up > with everything split up in multiple ascii files... > Lots of copying and pasting going on. Echoing Dave and Russ' comments: Sounds like you need/needed a little data munging script. I've written hundreds of those over the years, mostly in Perl. Next time before you spend hours/days/weekends copying and pasting you might want to paste a few lines of your data to a mailing list and explain what your desired state is. You'll probably get a dozen people sending you 3-15 line programs that do what you want (in various languages -- take your pick). HTH, j Omaha Perl Mongers: http://omaha.pm.org From jay at jays.net Sat Oct 15 09:59:15 2005 From: jay at jays.net (Jay Hannah) Date: Sat, 15 Oct 2005 11:59:15 -0500 Subject: [Omaha.pm] [olug] String parsing question In-Reply-To: <4346ACD0.5080508@shwisp.net> References: <9A8B75E3985324438F1BFA08B160E82057AEBA@suxsvr.willconsult.com> <4346ACD0.5080508@shwisp.net> Message-ID: <235496d30c55f0dbbb375638ec1a4b2c@jays.net> Adam Haeder wrote: > What's the best (fastest) way to get from this string: > > User 1 , User 2 , User 3 > > to this: > > user1 at a.com user2 at a.com user3 at a.com > > Consider that there could be x number of addresses on the line, so I > can't > always assume 3. On Oct 7, 2005, at 12:13 PM, Sam Tetherow wrote: > Since Jay hasn't replied yet I'll give a perl version ;) > > Quick and dirty, no data validation: > > #!/usr/bin/perl > > while() { > $_=~s/[^<]*<([^>]*)>/$1 /g; > print; > } -laugh- I'm /(in)?famous/! I stole Sam's regex and made it available via command line: $ perl -pe 's/[^<]*<([^>]*)>/$1 /g' inputfile.txt or $ cat inputfile.txt | perl -pe 's/[^<]*<([^>]*)>/$1 /g' The hardcore version of this might be via Text::Balanced. j Omaha Perl Mongers: http://omaha.pm.org From jay at jays.net Sat Oct 15 10:39:51 2005 From: jay at jays.net (Jay Hannah) Date: Sat, 15 Oct 2005 12:39:51 -0500 Subject: [Omaha.pm] http://perlcast.com/ - Podcasting Perl Message-ID: <69fef932dbf15aa7f7989e96e122f9d3@jays.net> Check it out! http://perlcast.com/ Who knew? j From jay at jays.net Mon Oct 17 20:38:20 2005 From: jay at jays.net (Jay Hannah) Date: Mon, 17 Oct 2005 22:38:20 -0500 Subject: [Omaha.pm] CGI.pm param() gotcha Message-ID: <8340097e5bf326c80f28c1f4905c1837@jays.net> 20 bonus points to anyone who can tell me why I made this change: 255,261c255,261 < $res->set_address (address1 => $q->param('gst_addr1'), < address2 => $q->param('gst_addr2'), < address3 => $q->param('gst_addr3'), < city => $q->param('gst_city'), < state => $q->param('gst_state'), < postal => $q->param('gst_zipcode'), < country_code => $q->param('gst_country_code')); --- > $res->set_address (address1 => scalar($q->param('gst_addr1')), > address2 => scalar($q->param('gst_addr2')), > address3 => scalar($q->param('gst_addr3')), > city => scalar($q->param('gst_city')), > state => scalar($q->param('gst_state')), > postal => scalar($q->param('gst_zipcode')), > country_code => scalar($q->param('gst_country_code'))); j Hint: $q->param('gst_addr3') is undefined. From jay at jays.net Mon Oct 17 20:41:36 2005 From: jay at jays.net (Jay Hannah) Date: Mon, 17 Oct 2005 22:41:36 -0500 Subject: [Omaha.pm] CGI.pm param() gotcha In-Reply-To: <8340097e5bf326c80f28c1f4905c1837@jays.net> References: <8340097e5bf326c80f28c1f4905c1837@jays.net> Message-ID: <43782f088e9ba29f91ff949bb335749c@jays.net> On Oct 17, 2005, at 10:38 PM, Jay Hannah wrote: > 20 bonus points to anyone who can tell me why I made this change: Gak! Here's a version that hopefully won't line wrap: 255,261c255,261 < $res->set_address ( < address1 => $q->param('gst_addr1'), < address2 => $q->param('gst_addr2'), < address3 => $q->param('gst_addr3'), < city => $q->param('gst_city'), < state => $q->param('gst_state'), < postal => $q->param('gst_zipcode'), < country_code => $q->param('gst_country_code')); --- > $res->set_address ( > address1 => scalar($q->param('gst_addr1')), > address2 => scalar($q->param('gst_addr2')), > address3 => scalar($q->param('gst_addr3')), > city => scalar($q->param('gst_city')), > state => scalar($q->param('gst_state')), > postal => scalar($q->param('gst_zipcode')), > country_code => scalar($q->param('gst_country_code'))); Sorry about that. Is that my fault or MailMan? j From kthompson at omnihotels.com Tue Oct 18 05:28:30 2005 From: kthompson at omnihotels.com (Kenneth Thompson) Date: Tue, 18 Oct 2005 07:28:30 -0500 Subject: [Omaha.pm] CGI.pm param() gotcha Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B035D6BFA@exchange2k3.omnihotels.net> Because the first way sends scalar references into the passed hashref, and the second sends scalar values into the passed hashref? -----Original Message----- On Oct 17, 2005, at 10:38 PM, Jay Hannah wrote: > 20 bonus points to anyone who can tell me why I made this change: < $res->set_address ( < address1 => $q->param('gst_addr1'), < address2 => $q->param('gst_addr2'), < address3 => $q->param('gst_addr3'), < city => $q->param('gst_city'), < state => $q->param('gst_state'), < postal => $q->param('gst_zipcode'), < country_code => $q->param('gst_country_code')); --- > $res->set_address ( > address1 => scalar($q->param('gst_addr1')), > address2 => scalar($q->param('gst_addr2')), > address3 => scalar($q->param('gst_addr3')), > city => scalar($q->param('gst_city')), > state => scalar($q->param('gst_state')), > postal => scalar($q->param('gst_zipcode')), > country_code => scalar($q->param('gst_country_code'))); From jhannah at omnihotels.com Tue Oct 18 15:04:21 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue, 18 Oct 2005 17:04:21 -0500 Subject: [Omaha.pm] FW: what lanague is your perl writen in? Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACD82@exchange2k3.omnihotels.net> Huh... Anyone smart enough to explain this kind of bootstrapping stuff to the group at a meeting? I'm certainly not... j -----Original Message----- From: Eli Criffield [mailto:eli at criffield.net] Sent: Tuesday, October 18, 2005 3:39 PM PyPy Python implemented in Python. see: http://codespeak.net/pypy/dist/pypy/doc/architecture.html According to some in the near future It'll be faster then the python writen in C and will take over as the most common python implementation. Eli From jhannah at omnihotels.com Tue Oct 18 15:09:04 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue, 18 Oct 2005 17:09:04 -0500 Subject: [Omaha.pm] htmlpp Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACD83@exchange2k3.omnihotels.net> What specific tasks did you use it for? j > -----Original Message----- > From: Sean J. Edwards > Sent: Wednesday, October 12, 2005 11:36 AM > Subject: PERL HTML Tool > > I have used this PERL script in the past. It is very handy and very > useful. > > Basically, the script makes web pages with relative links from the > "source" files that you create. > > It can be run from a cron job, it can be part of a cgi based tool, > wherever you need to auto or semi-auto generate content. > > http://www.imatix.com/html/htmlpp/ > > -- > -=Sean Edwards=- From jay at jays.net Fri Oct 21 17:21:23 2005 From: jay at jays.net (Jay Hannah) Date: Fri, 21 Oct 2005 19:21:23 -0500 Subject: [Omaha.pm] Job opportunity in West Hollywood, CA Message-ID: He scraped my email address off somewhere, so this is probably spam... But, hey, it's *almost* not spam, so I'm posting it. -grin- j Begin forwarded message: > From: Todd Cranston-Cuebas > Date: October 21, 2005 7:11:42 PM CDT > To: "'jay at jays.net'" > Subject: You love perl. We love perl programmers! > > Jay, > ? > From your web "presence" you clearly love perl. I wanted to let you > know that Ticketmaster is currently looking to expand our perl > programming team. If you're interested, or know others who might be, > please feel free to contact me. Ticketmaster.com has one of the > largest enterprise deployments of mod_perl, perl, linux, etc. It's a > great place where you can do what you love to do most, code perl. It's > also a great place to learn from a fantastic group of engineers. > ? > I should point out that we're located in West Hollywood, California. > Relocation will be provided should we all determine that we have a > win-win situation. > ? > I do hope to hear from you. > > Regards, > > Todd > > todd cranston-cuebas -- senior technical recruiter > tcc at ticketmaster.com > ticketmaster (NASDAQ: IACI) > 8800 sunset blvd . west hollywood, ca . 90069 > voice 310-360-2436 . mobile: 310-422-3347 > ? From jhannah at omnihotels.com Mon Oct 24 12:22:13 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Mon, 24 Oct 2005 14:22:13 -0500 Subject: [Omaha.pm] Class::Date - change once set Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACDE0@exchange2k3.omnihotels.net> Hola -- Is there any way to change a Class::Date value once one has been set? Right now my demo script is failing: My script: --- use Class::Date qw( date ); my $d1 = date "1970-01-01"; my $d2 = date "2000-01-01"; stuff($d1, $d2); print "[$d1][$d2]\n"; sub stuff { my ($d1, $d2) = @_; if ($d2 > $d1) { $d1 = $d2; # <---- I want to overwrite the existing $d1 here } print "[$d1][$d2]\n"; } --- When I run it: $ perl j.pl [2000-01-01 00:00:00][2000-01-01 00:00:00] [1970-01-01 00:00:00][2000-01-01 00:00:00] $d1 is getting a NEW object, not overwriting the original $d1, so when stuff() returns I have lost my change to $d1. Is there any way to change $d1 inside stuff()? I tried clone() and set() without any luck. Thanks! j From kthompson at omnihotels.com Mon Oct 24 13:25:27 2005 From: kthompson at omnihotels.com (Kenneth Thompson) Date: Mon, 24 Oct 2005 15:25:27 -0500 Subject: [Omaha.pm] Class::Date - change once set Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B036F7EE7@exchange2k3.omnihotels.net> Well, it's clumsy but it works. Maybe it could be written into the class as another clone option? use Class::Date qw( date ); my $d1 = Class::Date->new("1971-01-01"); my $d2 = Class::Date->new("2000-01-01"); print "[$d1][$d2]\n"; stuff($d1, $d2); print "[$d1][$d2]\n"; sub stuff { my ($d1, $d2) = @_; if ($d2 > $d1) { # $d1 = $d2; # <---- I want to overwrite the existing $d1 here foreach my $idx (0 .. 9) { $d1->[$idx] = $d2->[$idx]; } } } -----Original Message----- From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf Of Jay Hannah Sent: Monday, October 24, 2005 2:22 PM To: class-date at lists.dlux.hu Cc: omaha-pm at pm.org Subject: [Omaha.pm] Class::Date - change once set Hola -- Is there any way to change a Class::Date value once one has been set? Right now my demo script is failing: My script: --- use Class::Date qw( date ); my $d1 = date "1970-01-01"; my $d2 = date "2000-01-01"; stuff($d1, $d2); print "[$d1][$d2]\n"; sub stuff { my ($d1, $d2) = @_; if ($d2 > $d1) { $d1 = $d2; # <---- I want to overwrite the existing $d1 here } print "[$d1][$d2]\n"; } --- When I run it: $ perl j.pl [2000-01-01 00:00:00][2000-01-01 00:00:00] [1970-01-01 00:00:00][2000-01-01 00:00:00] $d1 is getting a NEW object, not overwriting the original $d1, so when stuff() returns I have lost my change to $d1. Is there any way to change $d1 inside stuff()? I tried clone() and set() without any luck. Thanks! j _______________________________________________ Omaha-pm mailing list Omaha-pm at pm.org http://mail.pm.org/mailman/listinfo/omaha-pm From dan at linder.org Mon Oct 24 19:12:46 2005 From: dan at linder.org (Daniel Linder) Date: Mon, 24 Oct 2005 21:12:46 -0500 (CDT) Subject: [Omaha.pm] Class::Date - change once set In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B036F7EE7@exchange2k3.omnihotels.net> References: <29AB736ABCE5C745ABF9C93B02F2C27B036F7EE7@exchange2k3.omnihotels.net> Message-ID: <1335.68.13.86.85.1130206366.squirrel@mail.linder.org> (I'm not all that versed on Object Oriented Programming so bear with me...) i thought the whold reason for the use of "my" when declaring variables was to limit their scope and keep from overlapping with other delcarations of the same variable name. Hence, the parent scope ('my $d1 = Class::Date->new("1971-01-01");') were protected from the subroutine scope declaration of d1 and d2. Doesn't the "our" declaration do what you want?? From the "man perlfunc": our EXPR An our declares the listed variables to be valid globals within the enclosing block, file, or eval. That is, it has the same scoping rules as a "my" declaration, but does not create a local variable. If more than one value is listed, the list must be placed in parentheses. The our declaration has no semantic effect unless "use strict vars" is in effect, in which case it lets you use the declared global variable without qualifying it with a package name. (But only within the lexical scope of the our declaration. In this it differs from "use vars", which is package scoped.) Here is what I came up with: #!/usr/bin/perl -w use Class::Date qw( date ); our $d1 = date "1970-01-01"; our $d2 = date "2000-01-01"; print "Before stuff: [$d1][$d2]\n"; stuff($d1, $d2); print "After stuff : [$d1][$d2]\n"; sub stuff { ??????? our ($d1, $d2) = @_; ??????? if ($d2 > $d1) { ??????????????? $d1 = $d2;?? # <---- I want to overwrite the existing $d1 here ??????? } ??????? print "Inside stuff: [$d1][$d2]\n"; } Dan On Mon, October 24, 2005 15:25, Kenneth Thompson wrote: > Well, it's clumsy but it works. Maybe it could be written into the class > as another clone option? > > use Class::Date qw( date ); > > my $d1 = Class::Date->new("1971-01-01"); > my $d2 = Class::Date->new("2000-01-01"); > > print "[$d1][$d2]\n"; > stuff($d1, $d2); > print "[$d1][$d2]\n"; > > sub stuff { > my ($d1, $d2) = @_; > if ($d2 > $d1) { > # $d1 = $d2; # <---- I want to overwrite the existing $d1 here > foreach my $idx (0 .. 9) { > $d1->[$idx] = $d2->[$idx]; > } > } > } > > > -----Original Message----- > From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf > Of Jay Hannah > Sent: Monday, October 24, 2005 2:22 PM > To: class-date at lists.dlux.hu > Cc: omaha-pm at pm.org > Subject: [Omaha.pm] Class::Date - change once set > > > Hola -- > > Is there any way to change a Class::Date value once one has been set? > Right now my demo script is failing: > > My script: > > --- > use Class::Date qw( date ); > > my $d1 = date "1970-01-01"; > my $d2 = date "2000-01-01"; > > stuff($d1, $d2); > print "[$d1][$d2]\n"; > > sub stuff { > my ($d1, $d2) = @_; > if ($d2 > $d1) { > $d1 = $d2; # <---- I want to overwrite the existing $d1 here > } > print "[$d1][$d2]\n"; > } > --- > > When I run it: > > $ perl j.pl > [2000-01-01 00:00:00][2000-01-01 00:00:00] > [1970-01-01 00:00:00][2000-01-01 00:00:00] > > $d1 is getting a NEW object, not overwriting the original $d1, so when > stuff() returns I have lost my change to $d1. > > Is there any way to change $d1 inside stuff()? I tried clone() and set() > without any luck. > > Thanks! > > j > > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm at pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm at pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm > - - - - "Wait for that wisest of all counselors, time." -- Pericles "I do not fear computer, I fear the lack of them." -- Isaac Asimov GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20051025/9632e161/attachment.html From jhannah at omnihotels.com Tue Oct 25 08:43:13 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue, 25 Oct 2005 10:43:13 -0500 Subject: [Omaha.pm] sort hackery Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACDE7@exchange2k3.omnihotels.net> So I've got this array of hashrefs that was built like this: push @arr, { code=>$prop, desc=>$desc, }; And I want to sort them alphabetically based of desc. So I do this: # Sort the list by descriptions @arr = sort sort_by_desc @arr; sub sort_by_desc { $a->{desc} cmp $b->{desc}; } And it worked, 2nd try. Yay! It appears I've learned a little Perl over the years. -grin- Custom sorting methods in Perl rule. Do any other languages allow you to define custom arbitrary sorting rulesets so easily? j From pterry2 at mac.com Tue Oct 25 19:38:04 2005 From: pterry2 at mac.com (Philip Terry) Date: Tue, 25 Oct 2005 19:38:04 -0700 Subject: [Omaha.pm] Downloading CPAN modules on G5 Mac In-Reply-To: <15691556.1130294214901.JavaMail.tmproductions@mac.com> References: <15691556.1130294214901.JavaMail.tmproductions@mac.com> Message-ID: <15474203.1130294284015.JavaMail.pterry2@mac.com> Hello, I have a G5 Mac and would like to install a module from the CPAN web site. When I tried this, I said "no" to manual configuration because I did not know what settings were appropriate. From the responses on the terminal, the download failed. From subsequent print out of the MyConfig.pm file, it would appear that the the MyConfig.pm file has a lot of uninitialized parameters. Would anyone know how to proceed to reach a situation where I can download for example, the following CPAN module: # sudo perl -MCPAN -e 'install Statistics::ChiSquare' Thanks, Philip M. Terry From jay at jays.net Tue Oct 25 19:43:21 2005 From: jay at jays.net (Jay Hannah) Date: Tue, 25 Oct 2005 21:43:21 -0500 Subject: [Omaha.pm] Downloading CPAN modules on G5 Mac In-Reply-To: <15474203.1130294284015.JavaMail.pterry2@mac.com> References: <15691556.1130294214901.JavaMail.tmproductions@mac.com> <15474203.1130294284015.JavaMail.pterry2@mac.com> Message-ID: <52f81eec41c34ac81c83464358ee0675@jays.net> On Oct 25, 2005, at 9:38 PM, Philip Terry wrote: > When I tried this, I said "no" to manual configuration because I did > not know what settings were appropriate. From the responses on the > terminal, the download failed. From subsequent print out of the > MyConfig.pm file, it would appear that the the MyConfig.pm file has a > lot of uninitialized parameters. > > Would anyone know how to proceed to reach a situation where I can > download for example, the following CPAN module: > > # sudo perl -MCPAN -e 'install Statistics::ChiSquare' Post all the output from that command to the list and we can try to help. Thanks, j From jay at jays.net Tue Oct 25 19:54:49 2005 From: jay at jays.net (Jay Hannah) Date: Tue, 25 Oct 2005 21:54:49 -0500 Subject: [Omaha.pm] Class::Date - change once set In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B036F7EE7@exchange2k3.omnihotels.net> References: <29AB736ABCE5C745ABF9C93B02F2C27B036F7EE7@exchange2k3.omnihotels.net> Message-ID: <807ed13bf9b39213dc7edde822830c22@jays.net> On Oct 24, 2005, at 3:25 PM, Kenneth Thompson wrote: > sub stuff { > my ($d1, $d2) = @_; > if ($d2 > $d1) { > # $d1 = $d2; # <---- I want to overwrite the existing $d1 here > foreach my $idx (0 .. 9) { > $d1->[$idx] = $d2->[$idx]; > } > } > } Yikes! Break encapsulation and jack the object's internals? I'll be doomed if the internal implementation of Class::Date ever changes... j From jay at jays.net Tue Oct 25 20:06:57 2005 From: jay at jays.net (Jay Hannah) Date: Tue, 25 Oct 2005 22:06:57 -0500 Subject: [Omaha.pm] Class::Date - change once set In-Reply-To: <1335.68.13.86.85.1130206366.squirrel@mail.linder.org> References: <29AB736ABCE5C745ABF9C93B02F2C27B036F7EE7@exchange2k3.omnihotels.net> <1335.68.13.86.85.1130206366.squirrel@mail.linder.org> Message-ID: <9e4ba951b2f41a018c991f58db0bd1a1@jays.net> On Oct 24, 2005, at 9:12 PM, Daniel Linder wrote: > Doesn't the "our" declaration do what you want?? From the "man > perlfunc": I never use "our". I tried to write a demo showing "our" doing something useful (and different from "my") and failed. Seems the same to me. Anyone else up to that challenge? Using "our" in my original Class::Date script didn't change the behavior any... j From dthacker9 at cox.net Tue Oct 25 21:28:42 2005 From: dthacker9 at cox.net (Dave Thacker) Date: Tue, 25 Oct 2005 23:28:42 -0500 Subject: [Omaha.pm] Downloading CPAN modules on G5 Mac In-Reply-To: <15474203.1130294284015.JavaMail.pterry2@mac.com> References: <15691556.1130294214901.JavaMail.tmproductions@mac.com> <15474203.1130294284015.JavaMail.pterry2@mac.com> Message-ID: <200510252328.42994.dthacker9@cox.net> On Tuesday 25 October 2005 21:38, Philip Terry wrote: > Hello, > > I have a G5 Mac and would like to install a module from the CPAN web site. > > When I tried this, I said "no" to manual configuration because I did not > know what settings were appropriate. You're usually safe taking the default settings. If you find they aren't working, blow them away and try again. I can't think of anything MCPAN would do to your OS config to break it. If you're *really* worried, take a backup before you start. There are several *ix commands that CPAN is going to want paths to. (more, ftp, etc) These vary by flavor of (Unix/Linux/OSX), so you may have to find them and enter them. Pick 3 or 4 ftp sites that are geographically close and you're set. You will probably see many entries that state "If you don't understand what this is, take the default". You can safely take the default on these. Good Luck! If you encounter problems, do as Jay requests, and post your output to the list. DT From kthompson at omnihotels.com Wed Oct 26 07:32:50 2005 From: kthompson at omnihotels.com (Kenneth Thompson) Date: Wed, 26 Oct 2005 09:32:50 -0500 Subject: [Omaha.pm] Class::Date - change once set Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B0373EC0B@exchange2k3.omnihotels.net> Actually, I'm not so sure this is as bad a thing at it seems on the surface. The perldoc states that it exposes the internal pieces via an array of parts/formats: ------------- INTERNALS This module uses operator overloading very heavily. I've found it quite stable, but I am afraid of it a bit. A Class::Date object is an array reference. ------------- Given that the array has been exposed and documented on purpose, I wouldn't think that this type of manipulation would be bad. Even if they change the array, it's setting one object's internals equal to the other objects internals. Is that the same as accessing the internals for manipulation? Of course the hard count reference (0..9) should be a little more dynamic in case the array size is increased for some reason. However- what about a whole different approach? Maybe a referenced workaround? use Class::Date qw( date ); #Clone a date object into and existing date object my $d1 = Class::Date->new("1971-01-01"); my $d1R = \$d1; my $d2 = Class::Date->new("2000-01-01"); print "[".$d1."][$d2]\n"; stuff($d1, $d2);$d1 = $$d1R; print "[$d1][$d2]\n"; sub stuff { my ($d1, $d2) = @_; if ($d2 > $d1) { $d1R = \$d2; # <---- I want to overwrite the existing $d1 here } } And for discussion- why my ($d1, $d2) = @_; and not ($d1, $d2) = @_; ? (by the way... The second way works the way you wanted it to) -----Original Message----- From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf Of Jay Hannah Sent: Tuesday, October 25, 2005 9:55 PM To: Perl Mongers of Omaha, Nebraska USA Subject: Re: [Omaha.pm] Class::Date - change once set On Oct 24, 2005, at 3:25 PM, Kenneth Thompson wrote: > sub stuff { > my ($d1, $d2) = @_; > if ($d2 > $d1) { > # $d1 = $d2; # <---- I want to overwrite the existing $d1 here > foreach my $idx (0 .. 9) { > $d1->[$idx] = $d2->[$idx]; > } > } > } Yikes! Break encapsulation and jack the object's internals? I'll be doomed if the internal implementation of Class::Date ever changes... j _______________________________________________ Omaha-pm mailing list Omaha-pm at pm.org http://mail.pm.org/mailman/listinfo/omaha-pm From pterry2 at mac.com Wed Oct 26 12:51:16 2005 From: pterry2 at mac.com (Philip Terry) Date: Wed, 26 Oct 2005 12:51:16 -0700 Subject: [Omaha.pm] Downloading CPAN modules on G5 Mac In-Reply-To: <52f81eec41c34ac81c83464358ee0675@jays.net> References: <15691556.1130294214901.JavaMail.tmproductions@mac.com> <15474203.1130294284015.JavaMail.pterry2@mac.com> <52f81eec41c34ac81c83464358ee0675@jays.net> Message-ID: <6496534.1130356276199.JavaMail.pterry2@mac.com> On Tuesday, October 25, 2005, at 07:43PM, Jay Hannah wrote: > >On Oct 25, 2005, at 9:38 PM, Philip Terry wrote: >> When I tried this, I said "no" to manual configuration because I did >> not know what settings were appropriate. From the responses on the >> terminal, the download failed. From subsequent print out of the >> MyConfig.pm file, it would appear that the the MyConfig.pm file has a >> lot of uninitialized parameters. >> >> Would anyone know how to proceed to reach a situation where I can >> download for example, the following CPAN module: >> >> # sudo perl -MCPAN -e 'install Statistics::ChiSquare' > >Post all the output from that command to the list and we can try to >help. > >Thanks, > >j > >_______________________________________________ >Omaha-pm mailing list >Omaha-pm at pm.org >http://mail.pm.org/mailman/listinfo/omaha-pm > > I am ataching two files: cpan_diagnostic.txt has the output, and myconfig_pm_G5.txt is the MyConfig.pm file after the attempt to install Statistics::ChiSquare module from CPAN site. Thanks, Philip M. Terry -------------- next part -------------- philip-terrys-power-mac-g5:~ mterry$ sudo perl -MCPAN -e 'install Statistics::ChiSquare' We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. Password: We have to reconfigure CPAN.pm due to following uninitialized parameters: cpan_home, keep_source_where, build_dir, build_cache, scan_cache, index_expire, gzip, tar, unzip, make, pager, makepl_arg, make_arg, make_install_arg, urllist, inhibit_startup_message, ftp_proxy, http_proxy, no_proxy, prerequisites_policy, cache_metadata /Users/mterry/.cpan/CPAN/MyConfig.pm initialized. CPAN is the world-wide archive of perl resources. It consists of about 100 sites that all replicate the same contents all around the globe. Many countries have at least one CPAN site already. The resources found on CPAN are easily accessible with the CPAN.pm module. If you want to use CPAN.pm, you have to configure it properly. If you do not want to enter a dialog now, you can answer 'no' to this question and I'll try to autoconfigure. (Note: you can revisit this dialog anytime later by typing 'o conf init' at the cpan prompt.) Are you ready for manual configuration? [yes] no The following questions are intended to help you with the configuration. The CPAN module needs a directory of its own to cache important index files and maybe keep a temporary mirror of CPAN files. This may be a site-wide directory or a personal directory. I see you already have a directory /Users/mterry/.cpan Shall we use it as the general CPAN build and cache directory? CPAN build and cache directory? [/Users/mterry/.cpan] If you want, I can keep the source files after a build in the cpan home directory. If you choose so then future builds will take the files from there. If you don't want to keep them, answer 0 to the next question. How big should the disk cache be for keeping the build directories with all the intermediate files? Cache size for build directory (in MB)? [10] By default, each time the CPAN module is started, cache scanning is performed to keep the cache size in sync. To prevent from this, disable the cache scanning with 'never'. Perform cache scanning (atstart or never)? [atstart] To considerably speed up the initial CPAN shell startup, it is possible to use Storable to create a cache of metadata. If Storable is not available, the normal index mechanism will be used. Cache metadata (yes/no)? [yes] The next option deals with the charset your terminal supports. In general CPAN is English speaking territory, thus the charset does not matter much, but some of the aliens out there who upload their software to CPAN bear names that are outside the ASCII range. If your terminal supports UTF-8, you say no to the next question, if it supports ISO-8859-1 (also known as LATIN1) then you say yes, and if it supports neither nor, your answer does not matter, you will not be able to read the names of some authors anyway. If you answer no, names will be output in UTF-8. Your terminal expects ISO-8859-1 (yes/no)? [yes] If you have one of the readline packages (Term::ReadLine::Perl, Term::ReadLine::Gnu, possibly others) installed, the interactive CPAN shell will have history support. The next two questions deal with the filename of the history file and with its size. If you do not want to set this variable, please hit SPACE RETURN to the following question. File to save your history? [/Users/mterry/.cpan/histfile] Number of lines to save? [100] The CPAN module can detect when a module that which you are trying to build depends on prerequisites. If this happens, it can build the prerequisites for you automatically ('follow'), ask you for confirmation ('ask'), or just ignore them ('ignore'). Please set your policy to one of the three values. Policy on building prerequisites (follow, ask or ignore)? [ask] The CPAN module will need a few external programs to work properly. Please correct me, if I guess the wrong path for a program. Don't panic if you do not have some of them, just press ENTER for those. To disable the use of a download program, you can type a space followed by ENTER. Where is your gzip program? [/usr/bin/gzip] Where is your tar program? [/usr/bin/tar] Where is your unzip program? [/usr/bin/unzip] Warning: make not found in PATH Where is your make program? [] Warning: lynx not found in PATH Where is your lynx program? [] Warning: wget not found in PATH Where is your wget program? [] Warning: ncftpget not found in PATH Where is your ncftpget program? [] Warning: ncftp not found in PATH Where is your ncftp program? [] Where is your ftp program? [/usr/bin/ftp] Warning: gpg not found in PATH Where is your gpg program? [] What is your favorite pager program? [/usr/bin/less] What is your favorite shell? [/bin/bash] Every Makefile.PL is run by perl in a separate process. Likewise we run 'make' and 'make install' in processes. If you have any parameters (e.g. PREFIX, LIB, UNINST or the like) you want to pass to the calls, please specify them here. If you don't understand this question, just press ENTER. Parameters for the 'perl Makefile.PL' command? Typical frequently used settings: PREFIX=~/perl non-root users (please see manual for more hints) Your choice: [] Parameters for the 'make' command? Typical frequently used setting: -j3 dual processor system Your choice: [] Parameters for the 'make install' command? Typical frequently used setting: UNINST=1 to always uninstall potentially conflicting files Your choice: [] Sometimes you may wish to leave the processes run by CPAN alone without caring about them. As sometimes the Makefile.PL contains question you're expected to answer, you can set a timer that will kill a 'perl Makefile.PL' process after the specified time in seconds. If you set this value to 0, these processes will wait forever. This is the default and recommended setting. Timeout for inactivity during Makefile.PL? [0] If you're accessing the net via proxies, you can specify them in the CPAN configuration or via environment variables. The variable in the $CPAN::Config takes precedence. Your ftp_proxy? [] Your http_proxy? [] Your no_proxy? [] commit: wrote /Users/mterry/.cpan/CPAN/MyConfig.pm CPAN: Storable loaded ok LWP not available CPAN: Net::FTP loaded ok Fetching with Net::FTP: ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz Going to read /Users/mterry/.cpan/sources/authors/01mailrc.txt.gz CPAN: Compress::Zlib loaded ok LWP not available Fetching with Net::FTP: ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz Going to read /Users/mterry/.cpan/sources/modules/02packages.details.txt.gz Database was generated on Mon, 03 Oct 2005 23:11:35 GMT HTTP::Date not available LWP not available Fetching with Net::FTP: ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz Going to read /Users/mterry/.cpan/sources/modules/03modlist.data.gz Going to write /Users/mterry/.cpan/Metadata Running install for module Statistics::ChiSquare Running make for D/DC/DCANTRELL/Statistics-ChiSquare-0.5.tar.gz LWP not available Fetching with Net::FTP: ftp://ftp.perl.org/pub/CPAN/authors/id/D/DC/DCANTRELL/Statistics-ChiSquare-0.5.tar.gz CPAN: Digest::MD5 loaded ok LWP not available Fetching with Net::FTP: ftp://ftp.perl.org/pub/CPAN/authors/id/D/DC/DCANTRELL/CHECKSUMS Checksum for /Users/mterry/.cpan/sources/authors/id/D/DC/DCANTRELL/Statistics-ChiSquare-0.5.tar.gz ok Scanning cache /Users/mterry/.cpan/build for sizes Statistics-ChiSquare-0.5/ Statistics-ChiSquare-0.5/Changes Statistics-ChiSquare-0.5/lib/ Statistics-ChiSquare-0.5/lib/Statistics/ Statistics-ChiSquare-0.5/lib/Statistics/ChiSquare.pm Statistics-ChiSquare-0.5/Makefile.PL Statistics-ChiSquare-0.5/MANIFEST Statistics-ChiSquare-0.5/README Statistics-ChiSquare-0.5/test.pl CPAN.pm: Going to build D/DC/DCANTRELL/Statistics-ChiSquare-0.5.tar.gz Checking if your kit is complete... Looks good Writing Makefile for Statistics::ChiSquare -- NOT OK Running make test Can't test without successful make Running make install make had returned bad status, install seems impossible philip-terrys-power-mac-g5:~ mterry$ pwd /Users/mterry -------------- next part -------------- philip-terrys-power-mac-g5:~/.cpan/CPAN mterry$ ls -al total 16 drwxr-xr-x 4 mterry mterry 136 Oct 24 14:55 . drwxr-xr-x 6 mterry mterry 204 Oct 24 14:56 .. -rw-r--r-- 1 root mterry 955 Oct 24 14:55 MyConfig.pm -rw-r--r-- 1 mterry mterry 3 Oct 24 14:52 MyConfig.pm~ philip-terrys-power-mac-g5:~/.cpan/CPAN mterry$ cat MyConfig.pm $CPAN::Config = { 'build_cache' => q[10], 'build_dir' => q[/Users/mterry/.cpan/build], 'cache_metadata' => q[1], 'cpan_home' => q[/Users/mterry/.cpan], 'ftp' => q[/usr/bin/ftp], 'ftp_proxy' => q[], 'getcwd' => q[cwd], 'gpg' => q[], 'gzip' => q[/usr/bin/gzip], 'histfile' => q[/Users/mterry/.cpan/histfile], 'histsize' => q[100], 'http_proxy' => q[], 'inactivity_timeout' => q[0], 'index_expire' => q[1], 'inhibit_startup_message' => q[0], 'keep_source_where' => q[/Users/mterry/.cpan/sources], 'lynx' => q[], 'make' => q[], 'make_arg' => q[], 'make_install_arg' => q[], 'makepl_arg' => q[], 'ncftp' => q[], 'ncftpget' => q[], 'no_proxy' => q[], 'pager' => q[/usr/bin/less], 'prerequisites_policy' => q[ask], 'scan_cache' => q[atstart], 'shell' => q[/bin/bash], 'tar' => q[/usr/bin/tar], 'term_is_latin' => q[1], 'unzip' => q[/usr/bin/unzip], 'urllist' => [], 'wget' => q[], }; 1; __END__ philip-terrys-power-mac-g5:~/.cpan/CPAN mterry$ pwd /Users/mterry/.cpan/CPAN philip-terrys-power-mac-g5:~/.cpan/CPAN mterry$ From dan at linder.org Wed Oct 26 13:57:42 2005 From: dan at linder.org (Daniel Linder) Date: Wed, 26 Oct 2005 15:57:42 -0500 (CDT) Subject: [Omaha.pm] Downloading CPAN modules on G5 Mac In-Reply-To: <6496534.1130356276199.JavaMail.pterry2@mac.com> References: <15691556.1130294214901.JavaMail.tmproductions@mac.com> <15474203.1130294284015.JavaMail.pterry2@mac.com> <52f81eec41c34ac81c83464358ee0675@jays.net> <6496534.1130356276199.JavaMail.pterry2@mac.com> Message-ID: <1729.68.13.86.85.1130360262.squirrel@mail.linder.org> On Wed, October 26, 2005 14:51, Philip Terry wrote: > I am ataching two files: cpan_diagnostic.txt has the output, and > myconfig_pm_G5.txt is the MyConfig.pm file after the attempt to install > Statistics::ChiSquare module from CPAN site. It looks like it can't find some basic commands it needs: Warning: make not found in PATH Where is your make program? [] Warning: lynx not found in PATH Where is your lynx program? [] Warning: wget not found in PATH Where is your wget program? [] Warning: ncftpget not found in PATH Where is your ncftpget program? [] Warning: ncftp not found in PATH Where is your ncftp program? [] Warning: gpg not found in PATH Where is your gpg program? [] The only one that I am faily certain is a pretty hard requirement is the "make" program.? Do you have your distributions standard compliment of development tools installed?? If so, check that your PATH variable includes the proper directory. Dan - - - - "Wait for that wisest of all counselors, time." -- Pericles "I do not fear computer, I fear the lack of them." -- Isaac Asimov GPG fingerprint:6FFD DB94 7B96 0FD8 EADF 2EE0 B2B0 CC47 4FDE 9B68 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20051026/332be48b/attachment.html From jay at jays.net Wed Oct 26 17:59:51 2005 From: jay at jays.net (Jay Hannah) Date: Wed, 26 Oct 2005 19:59:51 -0500 Subject: [Omaha.pm] Downloading CPAN modules on G5 Mac In-Reply-To: <1729.68.13.86.85.1130360262.squirrel@mail.linder.org> References: <15691556.1130294214901.JavaMail.tmproductions@mac.com> <15474203.1130294284015.JavaMail.pterry2@mac.com> <52f81eec41c34ac81c83464358ee0675@jays.net> <6496534.1130356276199.JavaMail.pterry2@mac.com> <1729.68.13.86.85.1130360262.squirrel@mail.linder.org> Message-ID: <93e1f22c76eea2f6520fca96495f9471@jays.net> On Oct 26, 2005, at 3:57 PM, Daniel Linder wrote: > Warning: make not found in PATH > Where is your make program? [] > > The only one that I am faily certain is a pretty hard requirement is > the "make" program.? Do you have your distributions standard > compliment of development tools installed?? If so, check that your > PATH variable includes the proper directory. Ya. In Mac speak, you need to install the "Mac OS X Developer Tools". Whenever you buy the OS there's a separate, optional CD in the bundle that is labeled as such. It's an easy install. I don't think you can download it. Once you do, you'll have all the Unixy build stuff you'll need for typical Perly stuff (make, gcc, gdb, cvs, etc.) It comes with a bunch of Cocoa GUI RDE stuff too if you're into that sort of thing, but I don't use those. j From jay at jays.net Wed Oct 26 19:13:39 2005 From: jay at jays.net (Jay Hannah) Date: Wed, 26 Oct 2005 21:13:39 -0500 Subject: [Omaha.pm] Class::Date - change once set In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B0373EC0B@exchange2k3.omnihotels.net> References: <29AB736ABCE5C745ABF9C93B02F2C27B0373EC0B@exchange2k3.omnihotels.net> Message-ID: <8589413abe134ff1e574cd07026425e2@jays.net> On Oct 26, 2005, at 9:32 AM, Kenneth Thompson wrote: > Actually, I'm not so sure this is as bad a thing at it seems on the > surface. The perldoc states that it > exposes the internal pieces via an array of parts/formats: > > ------------- > INTERNALS > This module uses operator overloading very heavily. I've found it quite > stable, but I am afraid of it a bit. > A Class::Date object is an array reference. > ------------- > > Given that the array has been exposed and documented on purpose, I > wouldn't think that this type of manipulation would be bad. Even if > they > change the array, it's setting one object's internals equal to the > other > objects internals. Is that the same as accessing the internals for > manipulation? In my opinion, breaking encapsulation is always a bad idea and should be avoided at all costs. What if... - The class changes to a hash implementation a year from now? - The package is (or someday starts to) keep counts inside its scope or UNIVERSAL so copying that value breaks something? - One of the elements of the array ref is supposed to be unique? Memory pointer? Database ID? Any persistence ID? - the package overrides the assignment operator, causing weird things to occur? Even if the module author tempts you, do not partake of the forbidden fruit. Breaking encapsulation just begs your code to break some day, a year from now, when you've forgotten all about this class and have much better things to be working on than some mystery thing that "used to work". Unnecessary risk with no upside. Fragile code that will shatter time and time again. > Of course the hard count reference (0..9) should be a > little more dynamic in case the array size is increased for some > reason. Yes, I agree -- If you're going to jump out of an airplane w/o a parachute, then landing on your feet is probably a good idea. I predict the fall will still kill you, though. -grin- Better yet, take a parachute with you! (Leave encapsulation intact!) > However- what about a whole different approach? Maybe a referenced > workaround? > > use Class::Date qw( date ); > #Clone a date object into and existing date object > > my $d1 = Class::Date->new("1971-01-01"); > my $d1R = \$d1; > my $d2 = Class::Date->new("2000-01-01"); > > print "[".$d1."][$d2]\n"; > stuff($d1, $d2);$d1 = $$d1R; > print "[$d1][$d2]\n"; > > > sub stuff { > my ($d1, $d2) = @_; > if ($d2 > $d1) { > $d1R = \$d2; # <---- I want to overwrite the existing $d1 here > } > } > > And for discussion- why > > my ($d1, $d2) = @_; > > and not > > ($d1, $d2) = @_; > > ? (by the way... The second way works the way you wanted it to) In both of those examples you're reusing a variable that's been scoped to be global throughout your program. As we all know, globals are another evil root of maintainability doom. Pretend our little demo is part of a larger (real world) program by expanding the demo to 2 files (a .pl and a .pm) and "use strict;" and you'll see that strict won't let you play those particular reindeer games: ---- $ cat j2.pl use strict; use Class::Date; use Printer; my $d1 = Class::Date->new("1971-01-01"); my $d2 = Class::Date->new("2000-01-01"); Printer::print($d1, $d2); $ cat Printer.pm package Printer; use strict; sub print { print "[$d1][$d2]\n"; } 1; $ perl j2.pl Global symbol "$d1" requires explicit package name at Printer.pm line 5. Global symbol "$d2" requires explicit package name at Printer.pm line 5. Compilation failed in require at j2.pl line 3. BEGIN failed--compilation aborted at j2.pl line 3. ---- The my ($x, $y, $z) = @_; idiom is how you know for sure that your sub/method has its own scoped copies of or references to the arguments that were just handed it. Two things I learned setting up this demo: (1) "use strict" doesn't detect scoping problems if you define multiple packages in the same file. Doh! I don't do this in real life anyway, but it surprised me. (2) You have to "use strict" in both files to get it to complain. I thought once you "use strict"'d anywhere in your program that it would protect you across all your packages. Not true! Note to self: DO explicitly type "use strict;" into EVERY Perl file to make sure you don't burn yourself! Encapsulation good. Globals bad. I'll solve my original problem by storing the Class::Date objects in a location that both my main and my package can access. (Attributes of a commonly accessible class...) I hope that helps, j long winded soap box dude P.S. Damian Conway's OO Perl book delivers the encapsulation lecture far better than I can. From jhannah at omnihotels.com Thu Oct 27 07:56:37 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Thu, 27 Oct 2005 09:56:37 -0500 Subject: [Omaha.pm] Class::Date - change once set Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACDF9@exchange2k3.omnihotels.net> > So... Did you ever figure out how to do it? I'm curious now ;) Well, no. AFAIK the original question I asked has no good solution, so I worked around it like I threatened to: > I'll solve my original problem by storing the Class::Date > objects in a location that both my main and my package can > access. (Attributes of a commonly accessible class...) I just tucked the objects into attributes of an object both code snippets had access to, and voila -- problem solved. So I can continue to update my 50+ CPAN dependencies several times every year w/o fear of my stuff breaking as long as those authors maintain backward compatibility. j "amongst the deadly sins of programming, even code forking is more manageable over the long haul than breaking encapsulation is" -Me From Scott.L.Miller at hp.com Thu Oct 27 08:21:20 2005 From: Scott.L.Miller at hp.com (Miller, Scott L (Omaha Networks)) Date: Thu, 27 Oct 2005 10:21:20 -0500 Subject: [Omaha.pm] sort hackery Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E9BC@omaexc11.americas.cpqcorp.net> Two questions for you: How large is the array you are sorting? Is response time important? If the answers are "quite large" and "yes", then there are several things you can do to speed up/optimize your sorting routine. If the answers don't match, then it's likely not worth the maintenance problems that come with the optimizations. For those that might be interested in reading more about sorting optimizations in Perl here's a short list of good material: A good introductory Perl sorting tutorial http://www.perlmonks.com/?node_id=128722 Resorting to sorting A discussion about when it does and doesn't make sense to use "optimized" sort routines http://www.perlmonks.com/?node_id=447633 Choosing the right sort [method] A tutorial that attempts to make transformation sorts more accessible to those new to the concept. http://www.perlmonks.com/?node_id=457993 Understanding xformation sorts Full disclosure: the last link was written by me. -Scott -----Original Message----- From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf Of Jay Hannah Sent: Tuesday, October 25, 2005 10:43 AM To: omaha-pm at pm.org Subject: [Omaha.pm] sort hackery So I've got this array of hashrefs that was built like this: push @arr, { code=>$prop, desc=>$desc, }; And I want to sort them alphabetically based of desc. So I do this: # Sort the list by descriptions @arr = sort sort_by_desc @arr; sub sort_by_desc { $a->{desc} cmp $b->{desc}; } And it worked, 2nd try. Yay! It appears I've learned a little Perl over the years. -grin- Custom sorting methods in Perl rule. Do any other languages allow you to define custom arbitrary sorting rulesets so easily? j _______________________________________________ Omaha-pm mailing list Omaha-pm at pm.org http://mail.pm.org/mailman/listinfo/omaha-pm From Scott.L.Miller at hp.com Thu Oct 27 08:40:45 2005 From: Scott.L.Miller at hp.com (Miller, Scott L (Omaha Networks)) Date: Thu, 27 Oct 2005 10:40:45 -0500 Subject: [Omaha.pm] FW: what lanague is your perl writen in? Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E9BD@omaexc11.americas.cpqcorp.net> Hmm, as I understand it, and I'm using C as my reference point, once you've got a compiler that successfully transforms C into something the machine can execute, then you can start writing the compiler itself in C. I'd imagine it's the same type of process using python. I'd personally think that there is no way python written in python will be faster than python written in C, unless python is low level enough to be able to compile programs directly into machine executable code. I'm just vaguely familiar with python, but I thought the whole point was that it was much higher level... -Scott -----Original Message----- From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf Of Jay Hannah Sent: Tuesday, October 18, 2005 5:04 PM To: omaha-pm at pm.org Cc: eli at criffield.net Subject: [Omaha.pm] FW: what lanague is your perl writen in? Huh... Anyone smart enough to explain this kind of bootstrapping stuff to the group at a meeting? I'm certainly not... j -----Original Message----- From: Eli Criffield [mailto:eli at criffield.net] Sent: Tuesday, October 18, 2005 3:39 PM PyPy Python implemented in Python. see: http://codespeak.net/pypy/dist/pypy/doc/architecture.html According to some in the near future It'll be faster then the python writen in C and will take over as the most common python implementation. Eli _______________________________________________ Omaha-pm mailing list Omaha-pm at pm.org http://mail.pm.org/mailman/listinfo/omaha-pm From jhannah at omnihotels.com Thu Oct 27 14:03:52 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Thu, 27 Oct 2005 16:03:52 -0500 Subject: [Omaha.pm] Class::Date easy e zeeness Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B031ACE04@exchange2k3.omnihotels.net> Life sure is easier using Class::Date objects than it is using/converting strings representing datetimes... Before use Date::Calc qw(Today_and_Now); my @today = Date::Calc::Today; my @ad = Date::Calc::Add_Delta_Days(@today,14); my @dd = Date::Calc::Add_Delta_Days(@ad,2); my $ad = "$ad[0]-$ad[1]-$ad[2]"; my $dd = "$dd[0]-$dd[1]-$dd[2]"; After use Control::DateTime; # Our Class::Date wrapper my $ad = Control::DateTime->new('today') + "14D"; my $dd = $ad + "2D"; Wheee! j From jay at jays.net Thu Oct 27 18:17:07 2005 From: jay at jays.net (Jay Hannah) Date: Thu, 27 Oct 2005 20:17:07 -0500 Subject: [Omaha.pm] CGI.pm param() gotcha In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B035D6BFA@exchange2k3.omnihotels.net> References: <29AB736ABCE5C745ABF9C93B02F2C27B035D6BFA@exchange2k3.omnihotels.net> Message-ID: > On Oct 17, 2005, at 10:38 PM, Jay Hannah wrote: >> 20 bonus points to anyone who can tell me why I made this change: > > < $res->set_address ( > < address1 => $q->param('gst_addr1'), > < address2 => $q->param('gst_addr2'), > < address3 => $q->param('gst_addr3'), > < city => $q->param('gst_city'), > < state => $q->param('gst_state'), > < postal => $q->param('gst_zipcode'), > < country_code => $q->param('gst_country_code')); > --- >> $res->set_address ( >> address1 => scalar($q->param('gst_addr1')), >> address2 => scalar($q->param('gst_addr2')), >> address3 => scalar($q->param('gst_addr3')), >> city => scalar($q->param('gst_city')), >> state => scalar($q->param('gst_state')), >> postal => scalar($q->param('gst_zipcode')), >> country_code => scalar($q->param('gst_country_code'))); On Oct 18, 2005, at 7:28 AM, Kenneth Thompson wrote: > Because the first way sends scalar references into the passed hashref, > and the second sends scalar values into the passed hashref? umm... maybe... -grin- What I do know is that CGI.pm is pretty weird. In scalar context if a param is not set param() returns undef. In array context if a param is not set param() returns *an empty array*. In Perl empty arrays listed in arrays squish themselves out of existence automatically. Like so: $ cat j.pl print join "|", ( 1, 2, 3, ( ), 5, 6, "\n"); print join "|", ( 1, 2, 3, undef, 5, 6, "\n"); $ perl j.pl 1|2|3|5|6| 1|2|3||5|6| Wacky huh? In my example (and why I made the change) address3 was not set. Due to the array context of each param call in the top version, the hash got squished and address3 got set to "city". (See that -- the whole => list shifted up one! Doh!) After the change, scalar context is explicit so address3 gets set to undef, city gets set to "Omaha", etc. Does that make sense? j From andy at petdance.com Thu Oct 27 19:12:48 2005 From: andy at petdance.com (Andy Lester) Date: Thu, 27 Oct 2005 21:12:48 -0500 Subject: [Omaha.pm] CGI.pm param() gotcha In-Reply-To: References: <29AB736ABCE5C745ABF9C93B02F2C27B035D6BFA@exchange2k3.omnihotels.net> Message-ID: <0285C7FE-E290-46FE-857D-FCEF4A2692EA@petdance.com> >> Because the first way sends scalar references into the passed >> hashref, >> and the second sends scalar values into the passed hashref? That's exactly right. > What I do know is that CGI.pm is pretty weird. In scalar context if a > param is not set param() returns undef. In array context if a param is > not set param() returns *an empty array*. That's right, and it's the Perl way. In both cases, (undef and empty array), the result evaluates to false. If it returned a one-element array, then that would evaluate to one, which is true. xoxo, Andy -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From jay at jays.net Thu Oct 27 20:14:03 2005 From: jay at jays.net (Jay Hannah) Date: Thu, 27 Oct 2005 22:14:03 -0500 Subject: [Omaha.pm] Kwiki::Scode Message-ID: Sweeet.... Tired of spammers destroying our wiki weekly, I installed Kwiki::Scode. Now when you try to edit our wiki you have to punch in a # to prove you're human (hopefully). We'll see if that's enough to keep the spam vermin away. http://omaha.pm.org/kwiki/ Thanks Kang-min Liu!! We'll see if it works. :) j From jhannah at omnihotels.com Fri Oct 28 10:24:01 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Fri, 28 Oct 2005 12:24:01 -0500 Subject: [Omaha.pm] Perl 6 // Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B037AF9CD@exchange2k3.omnihotels.net> Perl 6's // operator sure would be handy to have... Instead of my $store_RatesAvail = 1; if (defined $args{store_RatesAvail}) { $store_RatesAvail = $args{store_RatesAvail}; } I could have typed my $store_RatesAvail = $args{store_RatesAvail} // 1; j From andy at petdance.com Fri Oct 28 10:27:01 2005 From: andy at petdance.com (Andy Lester) Date: Fri, 28 Oct 2005 12:27:01 -0500 Subject: [Omaha.pm] Perl 6 // In-Reply-To: <29AB736ABCE5C745ABF9C93B02F2C27B037AF9CD@exchange2k3.omnihotels.net> References: <29AB736ABCE5C745ABF9C93B02F2C27B037AF9CD@exchange2k3.omnihotels.net> Message-ID: <20051028172701.GA22340@petdance.com> On Fri, Oct 28, 2005 at 12:24:01PM -0500, Jay Hannah (jhannah at omnihotels.com) wrote: > > Perl 6's // operator sure would be handy to have... Instead of > > my $store_RatesAvail = 1; > if (defined $args{store_RatesAvail}) { > $store_RatesAvail = $args{store_RatesAvail}; > } It will probably be in Perl 5.10, if I understand correctly. -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From jhannah at omnihotels.com Mon Oct 31 09:42:11 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Mon, 31 Oct 2005 11:42:11 -0600 Subject: [Omaha.pm] A..Z Message-ID: <29AB736ABCE5C745ABF9C93B02F2C27B037AF9D1@exchange2k3.omnihotels.net> -laugh- I love hitting my comments from 2001... # my $letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; # What was that? Bad form, bad form! -grin- -jhannah 7/6/01 my $letters = join "", "A".."Z"; j