From scott.l.miller at hp.com Tue Jun 1 11:22:37 2004 From: scott.l.miller at hp.com (Miller, Scott L (Omaha Networks)) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] a perl "table of operators" Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E58B@omaexc11.americas.cpqcorp.net> Ok, that's pretty cool. Now, where's the Perl 5 version? :-) -Scott -----Original Message----- From: omaha-pm-bounces@pm.org [mailto:omaha-pm-bounces@pm.org]On Behalf Of Mat Caughron Sent: Sunday, May 30, 2004 12:26 PM To: Perl Mongers of Omaha, Nebraska USA Subject: [Omaha.pm] a perl "table of operators" Hi Perl-ists: One look at this nice pdf and you'll just have to pass it along... http://www.ozonehouse.com/mark/blog/code/PeriodicTable.pdf Mat _______________________________________________ Omaha-pm mailing list Omaha-pm@pm.org http://www.pm.org/mailman/listinfo/omaha-pm From omaha-pm at jbisbee.com Tue Jun 1 12:14:26 2004 From: omaha-pm at jbisbee.com (Jeff Bisbee) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] a perl "table of operators" In-Reply-To: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E58B@omaexc11.americas.cpqcorp.net> References: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E58B@omaexc11.americas.cpqcorp.net> Message-ID: <20040601171425.GB4880@jbisbee.com> * Miller, Scott L (Omaha Networks) (scott.l.miller@hp.com) wrote: > Ok, that's pretty cool. Now, where's the Perl 5 version? :-) By the time I got to it, the link was broken :( -- Jeff Bisbee / omaha-pm@jbisbee.com / jbisbee.com From IrishMASMS at olug.org Tue Jun 1 16:31:00 2004 From: IrishMASMS at olug.org (OBrien, Timothy (Omaha Linux Users Group - OLUG)) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] a perl "table of operators" In-Reply-To: <20040601171425.GB4880@jbisbee.com> References: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E58B@omaexc11.americas.cpqcorp.net> <20040601171425.GB4880@jbisbee.com> Message-ID: <1070.68.13.178.64.1086125460.squirrel@admin.olug.org> > * Miller, Scott L (Omaha Networks) (scott.l.miller@hp.com) wrote: >> Ok, that's pretty cool. Now, where's the Perl 5 version? :-) > > By the time I got to it, the link was broken :( > > -- Jeff Bisbee / omaha-pm@jbisbee.com / jbisbee.com > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@pm.org > http://www.pm.org/mailman/listinfo/omaha-pm > Jeff - you might want to check on that. The link worked for me just fine today @ work, where I sent it to our graphics folks for some large scale color printing! ;) -- Timothy "Irish" O'Brien Publicity & Social activities chairperson Omaha Linux User's Group (OLUG) ---------------------------------------------- A: No. Q: Should I include e-mail quotations after my reply? ===================================================== An often repeated quote on news.admin.net-abuse.email: "Spam is not about content, it is about consent". -------------------------------- Microsoft: Where do you want to go today? Linux: Where do you want to go tomorrow? FreeBSD: Are you guys coming or what? From mat at phpconsulting.com Tue Jun 1 17:04:07 2004 From: mat at phpconsulting.com (Mat Caughron) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] a perl "table of operators" In-Reply-To: <1070.68.13.178.64.1086125460.squirrel@admin.olug.org> References: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E58B@omaexc11.americas.cpqcorp.net> <20040601171425.GB4880@jbisbee.com> <1070.68.13.178.64.1086125460.squirrel@admin.olug.org> Message-ID: Hey Tim: Print one for me, would you? :) Mat On Tue, 1 Jun 2004, OBrien, Timothy (Omaha Linux Users Group - OLUG) wrote: > > > > * Miller, Scott L (Omaha Networks) (scott.l.miller@hp.com) wrote: > >> Ok, that's pretty cool. Now, where's the Perl 5 version? :-) > > > > By the time I got to it, the link was broken :( > > > > -- Jeff Bisbee / omaha-pm@jbisbee.com / jbisbee.com > > _______________________________________________ > > Omaha-pm mailing list > > Omaha-pm@pm.org > > http://www.pm.org/mailman/listinfo/omaha-pm > > > > Jeff - you might want to check on that. The link worked for me just fine > today @ work, where I sent it to our graphics folks for some large scale > color printing! ;) > > > -- > Timothy "Irish" O'Brien > Publicity & Social activities chairperson > Omaha Linux User's Group (OLUG) > ---------------------------------------------- > A: No. > Q: Should I include e-mail quotations after my reply? > ===================================================== > An often repeated quote on news.admin.net-abuse.email: > > "Spam is not about content, it is about consent". > > -------------------------------- > Microsoft: Where do you want to go today? > Linux: Where do you want to go tomorrow? > FreeBSD: Are you guys coming or what? > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@pm.org > http://www.pm.org/mailman/listinfo/omaha-pm > From jay at jays.net Fri Jun 4 15:38:13 2004 From: jay at jays.net (Jay Hannah) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] IO::Multiplex, IO::Socket::INET Message-ID: <1978D1BE-B667-11D8-9DA1-000A95E317B8@jays.net> Wow. This is the coolest thing I have ever seen. Earlier today I was staring down the barrel of several weeks (probably) of writing low-level Socket and select logic to facilitate an UltraMonkey load balancing implementation for work. - Port 1: IO. Take inbound stream, break into work units, send each to a new TCP connection on port 2. - Port 2: O - Port 3: I. Take inbound streams (multiple sockets), flow all data to Port 1 outbound. To get all that working w/o blocking was going to take a while. That's a big select() and a whole bunch of loops... Then I found IO::Multiplex and IO::Socket::INET. Check out the IO::Multiplex POD http://search.cpan.org/~bbb/IO-Multiplex-1.08/lib/IO/Multiplex.pm Copy and paste the 2nd example ("simple chat server") and in 20(?) lines of Perl you have a multiple-connection chat server. Unreal. This is going to make my job way too easy (I hope). A big kudos to the authors! Wow. j Omaha Perl Mongers: http://omaha.pm.org From omaha-pm at jbisbee.com Fri Jun 4 17:21:34 2004 From: omaha-pm at jbisbee.com (Jeff Bisbee) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] IO::Multiplex, IO::Socket::INET In-Reply-To: <1978D1BE-B667-11D8-9DA1-000A95E317B8@jays.net> References: <1978D1BE-B667-11D8-9DA1-000A95E317B8@jays.net> Message-ID: <20040604222134.GB17964@jbisbee.com> * Jay Hannah (jay@jays.net) wrote: > A big kudos to the authors! Wow. You should really wrap your head around POE. You can write the same thing and easily tie in other POE components to do all kinds of fun, crazy, brain melting stuff. -- Jeff Bisbee / omaha-pm@jbisbee.com / jbisbee.com From omaha-pm at jbisbee.com Fri Jun 4 17:21:34 2004 From: omaha-pm at jbisbee.com (Jeff Bisbee) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] IO::Multiplex, IO::Socket::INET In-Reply-To: <1978D1BE-B667-11D8-9DA1-000A95E317B8@jays.net> References: <1978D1BE-B667-11D8-9DA1-000A95E317B8@jays.net> Message-ID: <20040604222134.GB17964@jbisbee.com> * Jay Hannah (jay@jays.net) wrote: > A big kudos to the authors! Wow. You should really wrap your head around POE. You can write the same thing and easily tie in other POE components to do all kinds of fun, crazy, brain melting stuff. -- Jeff Bisbee / omaha-pm@jbisbee.com / jbisbee.com From jay at jays.net Thu Jun 10 00:03:45 2004 From: jay at jays.net (Jay Hannah) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Re: [oma-python] an almost-switch statement In-Reply-To: <20040601211931.GD22213@gideon.cox.net> References: <20040601171858.GA22213@gideon.cox.net> <20040601211931.GD22213@gideon.cox.net> Message-ID: <8D10A35C-BA9B-11D8-883E-000A95E317B8@jays.net> [For the record, thehaas drug me into a Perl discussion on this list. I tried not to mention Perl at all... -grin-] On Jun 1, 2004, at 4:19 PM, thehaas@binary.net wrote: > I've used Perl quite a bit. Never used anonymous subroutines because > the syntax is ugly. It is? From example: http://www.python.org/doc/current/tut/ node6.html#SECTION006750000000000000000 Python: $ python >>> def make_incrementor(n): ... return lambda x: x + n ... >>> f = make_incrementor(42) >>> f(0) 42 >>> f(1) 43 I couldn't figure out how to do *exactly* that in Perl. I'm not sure I understand when you'd want to. You can skip the def step in Perl (I don't know if you could skip the def step in Python if your wanted to) thusly: $ perl -de 1 DB<1> $f = sub { $_[0] + 42 } DB<2> p &$f(0) 42 DB<3> p &$f(1) 43 > OO in Perl is even uglier. Indeed, it can be. I like Perl OO, but it certainly doesn't have native cascading public/private attribute inheritance. You can do it (and we do... a lot...), but it is ugly. > Will Perl 6 ever get out? ;) At OSCON 2003 Larry Wall and Damian Conway were talking about 2007. Parrot it coming along, apparently... j P.S. Contrary to my last post, Perl has a "Switch" module I didn't know about: http://search.cpan.org/~rgarcia/Switch-2.10/Switch.pm It's distributed in core Perl nowadays, so "use Switch" should be available by default. From hostetlerm at gmail.com Thu Jun 10 06:30:53 2004 From: hostetlerm at gmail.com (Mike Hostetler) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Re: [oma-python] an almost-switch statement In-Reply-To: <8D10A35C-BA9B-11D8-883E-000A95E317B8@jays.net> References: <20040601171858.GA22213@gideon.cox.net> <20040601211931.GD22213@gideon.cox.net> <8D10A35C-BA9B-11D8-883E-000A95E317B8@jays.net> Message-ID: On Thu, 10 Jun 2004 00:03:45 -0500, Jay Hannah wrote: > > > [For the record, thehaas drug me into a Perl discussion on this list. I > tried not to mention Perl at all... -grin-] Sorry about that. But, hey, we can all learn together, right? > > On Jun 1, 2004, at 4:19 PM, thehaas@binary.net wrote: > > I've used Perl quite a bit. Never used anonymous subroutines because > > the syntax is ugly. > > It is? From example: > > http://www.python.org/doc/current/tut/ > node6.html#SECTION006750000000000000000 > > Python: > > $ python > >>> def make_incrementor(n): > ... return lambda x: x + n > ... > >>> f = make_incrementor(42) > >>> f(0) > 42 > >>> f(1) > 43 > That's a horrible example of a lambda. I use it for one-liners that I need that it doesn't make sense to declare another function for. I also usually combine with with the map function. Here is an example of real working code that decodes a list of Unicode strings into latin-1: goodProcRef = map(lambda x: x.decode("latin-1"), goodProcRef) But these days most people are leaving lambda's behind and using generators for a lot of there stuff. http://c2.com/cgi/wiki?GeneratorsInPython http://www-106.ibm.com/developerworks/linux/library/l-pythrd.html > I couldn't figure out how to do *exactly* that in Perl. I'm not sure I > understand when you'd want to. You can skip the def step in Perl (I > don't know if you could skip the def step in Python if your wanted to) > thusly: > > $ perl -de 1 > DB<1> $f = sub { $_[0] + 42 } > DB<2> p &$f(0) > 42 > DB<3> p &$f(1) > 43 > It's a bit different than the Python version above -- basically the same as DB = lambda x: x+42 > > OO in Perl is even uglier. > > Indeed, it can be. I like Perl OO, but it certainly doesn't have native > cascading public/private attribute inheritance. You can do it (and we > do... a lot...), but it is ugly. I don't mind using modules in Perl that give back object and using their methods/attributes. But it get's funky sometimes. And I've never made my own class in Perl, but I've never really needed to. > > Will Perl 6 ever get out? ;) > > At OSCON 2003 Larry Wall and Damian Conway were talking about 2007. > Parrot it coming along, apparently... > Cool. I didn't know there was anything close to a formal announcement And how much code breakage will there be after that? ;) > j > > P.S. Contrary to my last post, Perl has a "Switch" module I didn't know > about: > > http://search.cpan.org/~rgarcia/Switch-2.10/Switch.pm > > It's distributed in core Perl nowadays, so "use Switch" should be > available by default. One thing about Perl is that there is a module of everything and anything. If it's not in core, CPAN makes it an easy install. Python is getting better -- I can find libraries for just about anything I want to do anymore, but it is lagging behind in the CPAN part, which it too bad. Thanks for the discussion! -- mikeh (TheHaas) From omaha-pm at jbisbee.com Thu Jun 10 07:59:51 2004 From: omaha-pm at jbisbee.com (Jeff Bisbee) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Re: [oma-python] an almost-switch statement In-Reply-To: References: <20040601171858.GA22213@gideon.cox.net> <20040601211931.GD22213@gideon.cox.net> <8D10A35C-BA9B-11D8-883E-000A95E317B8@jays.net> Message-ID: <20040610125951.GB16599@jbisbee.com> * Mike Hostetler (hostetlerm@gmail.com) wrote: > And how much code breakage will there be after that? ;) There is another project called Ponie - "Perl On New Internal Engine" http://opensource.fotango.com/software/ponie/faq Basically they're porting Perl 5 to run on top of Parrot. -- Jeff Bisbee / omaha-pm@jbisbee.com / jbisbee.com From omaha-pm at jbisbee.com Thu Jun 10 07:59:51 2004 From: omaha-pm at jbisbee.com (Jeff Bisbee) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Re: [oma-python] an almost-switch statement In-Reply-To: References: <20040601171858.GA22213@gideon.cox.net> <20040601211931.GD22213@gideon.cox.net> <8D10A35C-BA9B-11D8-883E-000A95E317B8@jays.net> Message-ID: <20040610125951.GB16599@jbisbee.com> * Mike Hostetler (hostetlerm@gmail.com) wrote: > And how much code breakage will there be after that? ;) There is another project called Ponie - "Perl On New Internal Engine" http://opensource.fotango.com/software/ponie/faq Basically they're porting Perl 5 to run on top of Parrot. -- Jeff Bisbee / omaha-pm@jbisbee.com / jbisbee.com From jay at jays.net Thu Jun 10 18:25:47 2004 From: jay at jays.net (Jay Hannah) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] HTML::Recorder Message-ID: <80D5C6D3-BB35-11D8-9F5E-000A95E317B8@jays.net> From: Dave Thacker [mailto:dthacker@omnihotels.com] > I love perl. > http://www.perl.com/pub/a/2004/06/04/recorder.html Wow. That's pretty neat. It never even occurred to me that one could send a browser (like IE) through a Perl proxy and use that conduit for all sorts of auto-detection/automation evil... Mwoo ha ha*, j * evil laugh From omaha-pm at jbisbee.com Thu Jun 10 21:44:02 2004 From: omaha-pm at jbisbee.com (Jeff Bisbee) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] HTML::Recorder In-Reply-To: <80D5C6D3-BB35-11D8-9F5E-000A95E317B8@jays.net> References: <80D5C6D3-BB35-11D8-9F5E-000A95E317B8@jays.net> Message-ID: <20040611024402.GA15037@jbisbee.com> * Jay Hannah (jay@jays.net) wrote: > Wow. That's pretty neat. It never even occurred to me that one could > send a browser (like IE) through a Perl proxy and use that conduit for > all sorts of auto-detection/automation evil... Recorders only short coming is that can't work with HTTPS (not that it matters much) Also the command line program 'mech-dump' rocks. You can give it a URL or a file and dumps forms (and optional links and images). It's great when you need to build a mechanize script. Just go to the site you want to "mechanize" and save each page as you go. Then run mech-dump against the local html files and you save a TON of time :) -- Jeff Bisbee / omaha-pm@jbisbee.com / jbisbee.com From td3201 at yahoo.com Fri Jun 11 00:23:43 2004 From: td3201 at yahoo.com (Terry) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] HTML::Recorder In-Reply-To: <80D5C6D3-BB35-11D8-9F5E-000A95E317B8@jays.net> Message-ID: <20040611052343.39937.qmail@web60301.mail.yahoo.com> Doh, that link takes you to a 500 error... --- Jay Hannah wrote: > > From: Dave Thacker [mailto:dthacker@omnihotels.com] > > I love perl. > > http://www.perl.com/pub/a/2004/06/04/recorder.html > > Wow. That's pretty neat. It never even occurred to > me that one could > send a browser (like IE) through a Perl proxy and > use that conduit for > all sorts of auto-detection/automation evil... > > Mwoo ha ha*, > > j > > * evil laugh > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@pm.org > http://www.pm.org/mailman/listinfo/omaha-pm ===== Terry __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From dan at linder.org Fri Jun 11 13:03:32 2004 From: dan at linder.org (Daniel Linder) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] HTML::Recorder In-Reply-To: <20040611052343.39937.qmail@web60301.mail.yahoo.com> References: <80D5C6D3-BB35-11D8-9F5E-000A95E317B8@jays.net> <20040611052343.39937.qmail@web60301.mail.yahoo.com> Message-ID: <59654.12.160.138.6.1086977012.squirrel@12.160.138.6> Not last night, nor just at 1300 today... Got the "Web Testing with HTTP::Recorder" by Linda Julien... Please try again... Dan Terry said: > Doh, that link takes you to a 500 error... > > > --- Jay Hannah wrote: >> >> From: Dave Thacker [mailto:dthacker@omnihotels.com] >> > I love perl. >> > http://www.perl.com/pub/a/2004/06/04/recorder.html >> >> Wow. That's pretty neat. It never even occurred to >> me that one could >> send a browser (like IE) through a Perl proxy and >> use that conduit for >> all sorts of auto-detection/automation evil... >> >> Mwoo ha ha*, >> >> j >> >> * evil laugh >> >> _______________________________________________ >> Omaha-pm mailing list >> Omaha-pm@pm.org >> http://www.pm.org/mailman/listinfo/omaha-pm > > > ===== > Terry > > > > > __________________________________ > Do you Yahoo!? > Friends. Fun. Try the all-new Yahoo! Messenger. > http://messenger.yahoo.com/ > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@pm.org > http://www.pm.org/mailman/listinfo/omaha-pm > -- Daniel Linder From ken at bitsko.slc.ut.us Fri Jun 11 08:49:01 2004 From: ken at bitsko.slc.ut.us (Ken MacLeod) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Union Pacific? Message-ID: Anyone here from or familiar with Union Pacific? I've got a nibble on a contract position there and I'm wondering what they're like. Are they well-organized, have clear direction and development plans, use good practices like test-first, small releases, etc? Please e-mail or call on 515-222-5993, thanks! -- Ken From jay at jays.net Fri Jun 11 07:56:15 2004 From: jay at jays.net (Jay Hannah) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] HTML::Recorder In-Reply-To: <20040611052343.39937.qmail@web60301.mail.yahoo.com> References: <20040611052343.39937.qmail@web60301.mail.yahoo.com> Message-ID: On Jun 11, 2004, at 12:23 AM, Terry wrote: > Doh, that link takes you to a 500 error... http://www.perl.com/pub/a/2004/06/04/recorder.html Weird... I hit it multiple times and it failed 20% of the time. Try hitting reload a couple times, you should get it. Looks like somebody tweaked some code and didn't restart their mod_perl Apache. Happens to us all the time. -grin- j From omaha.pm.knitter at recursor.net Fri Jun 11 02:11:16 2004 From: omaha.pm.knitter at recursor.net (omaha.pm.knitter@recursor.net) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] HTML::Recorder In-Reply-To: <20040611052343.39937.qmail@web60301.mail.yahoo.com> References: <80D5C6D3-BB35-11D8-9F5E-000A95E317B8@jays.net> Message-ID: <3.0.6.32.20040611021116.0098b8e0@pop.samfans.org> At 10:23 PM 6/10/2004 -0700, Terry wrote: >Doh, that link takes you to a 500 error... > > >--- Jay Hannah wrote: >> >> From: Dave Thacker [mailto:dthacker@omnihotels.com] >> > I love perl. http://www.perl.com/pub/a/2004/06/04/recorder.html >> Try again. A 500 error means the server is busy and your browser's request timed out before it got an answer. I suppose it's ~possible~ all the omaha-pm people trying to download the page at once caused an overload on the perl.com server. -Sidney From jay at jays.net Fri Jun 11 20:39:46 2004 From: jay at jays.net (Jay Hannah) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Re: [oma-python] an almost-switch statement In-Reply-To: References: <20040601171858.GA22213@gideon.cox.net> <20040601211931.GD22213@gideon.cox.net> <8D10A35C-BA9B-11D8-883E-000A95E317B8@jays.net> Message-ID: <62BB8D8A-BC11-11D8-BDAD-000A95E317B8@jays.net> On Jun 10, 2004, at 6:30 AM, Mike Hostetler wrote: > Here is an example of real working code that decodes a list of Unicode > strings into latin-1: > goodProcRef = map(lambda x: x.decode("latin-1"), goodProcRef) How do you use that? (Can I get some context code?) > But these days most people are leaving lambda's behind and using > generators for a lot of there stuff. > > http://c2.com/cgi/wiki?GeneratorsInPython > http://www-106.ibm.com/developerworks/linux/library/l-pythrd.html My brain just melted. -grin- > It's a bit different than the Python version above -- basically the > same as > DB = lambda x: x+42 Ya. Perl $f = sub { $_[0] + 42 } > I don't mind using modules in Perl that give back object and using > their methods/attributes. But it get's funky sometimes. And I've > never made my own class in Perl, but I've never really needed to. my $m = new Mike; print $m->status; package Mike; sub new { bless {}; } sub status { ref($_[0]) . " rules!"; } Grin, j From jay at jays.net Sun Jun 13 22:08:10 2004 From: jay at jays.net (Jay Hannah) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Re: [oma-python] mapping lambdas and other things In-Reply-To: <20040613182207.GA3722@gideon.cox.net> References: <20040601171858.GA22213@gideon.cox.net> <20040601211931.GD22213@gideon.cox.net> <8D10A35C-BA9B-11D8-883E-000A95E317B8@jays.net> <62BB8D8A-BC11-11D8-BDAD-000A95E317B8@jays.net> <20040613182207.GA3722@gideon.cox.net> Message-ID: <10FB67CE-BDB0-11D8-953E-000A95E317B8@jays.net> On Jun 13, 2004, at 1:22 PM, thehaas@binary.net wrote: > On Fri, Jun 11, 2004 at 08:39:46PM -0500, Jay Hannah wrote: >> >> On Jun 10, 2004, at 6:30 AM, Mike Hostetler wrote: >>> Here is an example of real working code that decodes a list of >>> Unicode >>> strings into latin-1: >>> goodProcRef = map(lambda x: x.decode("latin-1"), goodProcRef) >> >> How do you use that? (Can I get some context code?) > > The map function applies a function to every item in a list, returning > of list of the result. You can do the same thing with a for-loop, but > using the map function is much faster. > > In Perl, it would be something like: > > @decoded = []; > for $p in (@goodProcRef) { > push(@decoded,$p->decode()); > } > @goodProcRef=@decoded; Ah. Thanks. Perl has a map function too, BTW (perldoc -f map). I didn't realize Python's map does the exact same thing. for loops also create references to each element in an array and place it in the default variable $_, so you can do things like for (@objects) { $_->decode("latin-1") } or for (@strings) { s/foo/bar/ } Ooo... I just discovered "pydoc map"... j From jay at jays.net Fri Jun 18 22:08:51 2004 From: jay at jays.net (Jay Hannah) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Re: [olug] bash help (awk/sed) In-Reply-To: <40D32C41.4090403@nicusa.com> References: <1087573501.40d30dfd90bc8@webmail.nj-onramp.com> <1087580321.40d328a1e8cdd@webmail.nj-onramp.com> <40D32C41.4090403@nicusa.com> Message-ID: On Jun 18, 2004, at 12:54 PM, Sam Tetherow wrote: > We don't need to, it is pretty self evident that if you wanted to do > this project the easy way it would have been done in perl. > > And most of us being the purist hackers that we are would not want to > interfer with someone who is obviously trying to accomplish a task in > a convoluted manner for the pure joy of having accomplished something > trivial in a difficult manner using nothing but the virtual equivalent > of duct-tape and a pen-knife. > > :) LOL Wait a minute... are you saying Perl doesn't make good duct tape, nor a good pen-knife?! Blasphemer! Damn I'm a fickle jealot... I hacked out the obvious solution to the problem. In Perl, of course. Here you go: ''=~('('.'?' .'{'.( '`'|'%').("\["^ '-').('`'| '!').('`'|',').'"' .('!'^'+') .('['^ '+').('['^')').('`'| ')').('`'|'.').('['^ '/').('{'^'[').('\\'). '"'.'\\'.'\\'.(('`')| '.').('`'^'/').('`'|'-' ).('`'|'!').(('`')| '(').('`'|'!').('{'^'[').( '`'^',').('`'| ')').('`'|'.').('['^'.').('[' ^'#').('{'^'[' ).('{'^'.').('['^'(').('`'|'%'). ('['^')').('['^ '(').('{'^'[').('`'^"'").('['^')'). ('`'|'/').('['^ '.').('['^'+').('{'^'[').('{'^(')')).( '['^'.').("\`"| ',').('`'|'%').('['^'(').'!'.'\\'.'\\'.( '`'|'.').'\\'. '\\'.('`'|'.').'\\'.'"'.';'.('!'^('+')).( '['^'+').('['^ ')').('`'|')').('`'|'.').('['^'/').(('{')^ '[').'\\'.'"'.('`'^'.').('`'|'/').('['^'/').('{'^'[').('`' |'!').('['^'(').('{'^'[').('`'|'#').('`'|'/').('`'|('/')).( '`'|',').('{'^'[').('`'|'!').('['^'(').('{'^'[').('['^'/') .('`'|'(').('`'|'%').('{'^'[').('`'^'/').('`'|'-').('`'|'!' ).('`'|'(').('`'|'!').('{'^'[').('{'^'+').('`'|'%').(('[')^ ')').('`'|',').('{'^'[').('`'^'-').('`'|'/').('`'|('.')).( '`'|"'").('`'|'%').('['^')').('['^'(').','.('{'^'['). ((( '`'))|'"').('['^'.').('['^'/').('{'^'[').('`'|'('). ((( '`'))|'%').('['^'"').('{'^'[').'-'.('-'). '\\'.''. ((( '\\'))).('`'|'.').'\\'.'\\'.('`'|'.'). ('\\'). '"' .';'. ('!'^'+').('['^'+').('['^')'). (('`')| ')' ).('`'|'.').('['^'/').(('{')^ ('[')). ((( '\\'))). '"'.("\{"^ '[').( ('{')^ (( '['))). ('{'^'[' ).('[' ^'/'). +( '`'|'(' ).("\`"| '%'). ('['^ ( '"')). ('{'^'[' ).+( '['^ '/').( '['^')'). ('[' ^'"' ).'!' .('\\'). '\\' .''. ('`'| ('.')). '\\' .''. '\\' .('`'| '.') .''. '\\' .(( '"') ).(( ';') ).( '!' ^(( '+' ))) .+( '!' ^(( '+' ))) .(( '"' )). '}' .+ (( ')'))) ;( $: )='.' ^+ (( '~'));$~ =( '@' )|(( '(')) ;( $^) ="\)"^ '['; $/= '`'| "\.";$,= '(' ^'}' ;($\)= ('`')| "\!";$:= ')'^'}' Yes, seriously. Paste that into olug.pl or whatever and "perl olug.pl". You'll be amused. Maybe. In any event, I was amused and everyone will agree that that is what's important. -grin- j Omaha Perl Mongers: http://omaha.pm.org P.S. Mike cheated. He used ls in his "awk for everything" solution. Boo. Certified 100% Perl: opendir(D, "."); foreach $f (readdir D) { open (I, $f); while () { /^(\d{6}-\w)/ && print "$1,$f\n"; } } > > troehr@nj-onramp.com wrote: >> Now we're just waiting for the Perl Mongers to chime in... ;^) >> Later, >> Tom >> Quoting Mike Hostetler : >>> On Fri, 18 Jun 2004 10:45:01 -0500, troehr@nj-onramp.com >>> wrote: >>> >>>> Or to avoid awk, >>> >>> Or use awk for everything: >>> >>> for f in `ls -1 *.txt`; do >>> awk --assign infile=$f '/[0-9]+?-[A-F]/ {print $0 "," infile}' $f >>> done >>> >>> >>> -- mikeh From jay at jays.net Fri Jun 18 22:11:36 2004 From: jay at jays.net (Jay Hannah) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Re: [olug] bash help (awk/sed) In-Reply-To: References: <1087573501.40d30dfd90bc8@webmail.nj-onramp.com> <1087580321.40d328a1e8cdd@webmail.nj-onramp.com> <40D32C41.4090403@nicusa.com> Message-ID: <6026B215-C19E-11D8-8759-000A95E317B8@jays.net> On Jun 18, 2004, at 10:08 PM, Jay Hannah wrote: > Damn I'm a fickle jealot... What the hellot is a jealot? I think I meant "zealot"... > '[').'\\'.'"'.('`'^'.').('`'|'/').('['^'/').('{'^'[').('`' > |'!').('['^'(').('{'^'[').('`'|'#').('`'|'/').('`'|('/')).( > '`'|',').('{'^'[').('`'|'!').('['^'(').('{'^'[').('['^'/') Oops. 11th '(' was a typo for '{'. Kidding. j From jay at jays.net Sat Jun 19 00:14:02 2004 From: jay at jays.net (Jay Hannah) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Sort quickie Message-ID: <7A626BB0-C1AF-11D8-8759-000A95E317B8@jays.net> I had a bunch of hash keys that were dates in MMDDYYYY format. I wanted to get a sorted list of the keys. Perl to the rescue! Have y'all configured custom sort subroutines before? They're cool... The real code in context... ------------ print "\n\nGroup pickup by cap_date (running total):\n"; foreach (sort sort_by_cap_date keys %{$group_pickup{by_cap_date}}) { my $val = $group_pickup{by_cap_date}{$_}; next if $val == 0; print "$_: $val\n"; } } sub sort_by_cap_date ($$) { # We have to throw some mojo here since capdate is MMDDYYYY and obviously # we can't sort until we turn it into YYYYMMDD... -jhannah 6/14/04 my ($a, $b) = @_; for ($a, $b) { s/(\d\d)(\d\d)(\d\d\d\d)/$3$1$2/; } $a <=> $b; } --------------- Same idea, distilled out to see the results easier and so you can play with it: --------------- my @dates = qw( 05012003 02012004 11012002 ); print join ", ", sort @dates; print "\n"; print join ", ", sort by_date @dates; print "\n"; sub by_date ($$) { my ($a, $b) = @_; for ($a, $b) { s/(\d\d)(\d\d)(\d\d\d\d)/$3$1$2/; } $a <=> $b; } ---------------- "sort" just does an ASCII sort, which isn't in date order for MMDDYYYY dates. Instead, "sort by_date" does a comparison after converting MMDDYYYY into YYYYMMDD, which does sort dates correctly. It doesn't munge the real values though. Neat, huh? perldoc -f sort j From jay at jays.net Sat Jun 19 00:34:45 2004 From: jay at jays.net (Jay Hannah) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Re: [olug] bash help (awk/sed) In-Reply-To: <40D3B401.9010503@cox.net> References: <1087573501.40d30dfd90bc8@webmail.nj-onramp.com> <1087580321.40d328a1e8cdd@webmail.nj-onramp.com> <40D32C41.4090403@nicusa.com> <40D3B401.9010503@cox.net> Message-ID: <5F4C7E20-C1B2-11D8-8759-000A95E317B8@jays.net> On Jun 18, 2004, at 10:33 PM, Thom Harrison wrote: > I'm amused. Could you tell us how in the world you got the camel to > say that!? Ancient Chinese Secret: http://search.cpan.org/~asavige/Acme-EyeDrops-1.44/lib/Acme/EyeDrops.pm j From dan at linder.org Sat Jun 19 13:13:41 2004 From: dan at linder.org (Daniel Linder) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Sort quickie In-Reply-To: <7A626BB0-C1AF-11D8-8759-000A95E317B8@jays.net> References: <7A626BB0-C1AF-11D8-8759-000A95E317B8@jays.net> Message-ID: <19249.68.13.153.230.1087668821.squirrel@68.13.153.230> Excellent addition to the list. Going to have to pass this around work. Dan Jay Hannah said: > > I had a bunch of hash keys that were dates in MMDDYYYY format. I wanted > to get a sorted list of the keys. Perl to the rescue! Have y'all > configured custom sort subroutines before? They're cool... ...deleted... > Neat, huh? > > perldoc -f sort > > j > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@pm.org > http://www.pm.org/mailman/listinfo/omaha-pm > -- Daniel Linder From m0ntar3 at cox.net Sat Jun 19 18:28:55 2004 From: m0ntar3 at cox.net (=?ISO-8859-1?Q?m=D8ntar3?=) Date: Mon Aug 2 21:33:59 2004 Subject: [Omaha.pm] Sort quickie In-Reply-To: <7A626BB0-C1AF-11D8-8759-000A95E317B8@jays.net> References: <7A626BB0-C1AF-11D8-8759-000A95E317B8@jays.net> Message-ID: <40D4CC37.8040502@cox.net> I use(d) that functionality to sort tabular data (two-dimensional arrays, or an array hashes)---work(s|ed) well with CGI, allowing user(s) to specify what column to sort on (and hides detail like comparisons of text vs numerals vs dates in the called function). It's about as useful as the Unix "find" utility. Jay Hannah wrote: > > I had a bunch of hash keys that were dates in MMDDYYYY format. I > wanted to get a sorted list of the keys. Perl to the rescue! Have > y'all configured custom sort subroutines before? They're cool... > > The real code in context... > ------------ > print "\n\nGroup pickup by cap_date (running total):\n"; > foreach (sort sort_by_cap_date keys %{$group_pickup{by_cap_date}}) { > my $val = $group_pickup{by_cap_date}{$_}; > next if $val == 0; > print "$_: $val\n"; > } > } > > sub sort_by_cap_date ($$) { > # We have to throw some mojo here since capdate is MMDDYYYY and > obviously > # we can't sort until we turn it into YYYYMMDD... -jhannah 6/14/04 > my ($a, $b) = @_; > for ($a, $b) { > s/(\d\d)(\d\d)(\d\d\d\d)/$3$1$2/; > } > $a <=> $b; > } > --------------- > > Same idea, distilled out to see the results easier and so you can play > with it: > --------------- > my @dates = qw( 05012003 02012004 11012002 ); > print join ", ", sort @dates; > print "\n"; > print join ", ", sort by_date @dates; > print "\n"; > > sub by_date ($$) { > my ($a, $b) = @_; > for ($a, $b) { > s/(\d\d)(\d\d)(\d\d\d\d)/$3$1$2/; > } > $a <=> $b; > } > ---------------- > > "sort" just does an ASCII sort, which isn't in date order for MMDDYYYY > dates. Instead, "sort by_date" does a comparison after converting > MMDDYYYY into YYYYMMDD, which does sort dates correctly. It doesn't > munge the real values though. > > Neat, huh? > > perldoc -f sort > > j > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@pm.org > http://www.pm.org/mailman/listinfo/omaha-pm >