From jay at jays.net Wed Oct 1 09:07:32 2008 From: jay at jays.net (jay at jays.net) Date: Wed, 01 Oct 2008 12:07:32 -0400 Subject: [Omaha.pm] Redhat perl what a tragedy Message-ID: <854a63111f9b25d2d0f99cb0a80f8a2b@jays.net> A fix is available now, apparently: http://www.cyberciti.biz/tips/rhel-centos-perl-bug-fix-update.html Red Hat / CentOS Linux 5.x: Perl Performance Bug Fix Available j From jay at jays.net Wed Oct 1 12:34:34 2008 From: jay at jays.net (jay at jays.net) Date: Wed, 01 Oct 2008 15:34:34 -0400 Subject: [Omaha.pm] My first hash slice Message-ID: <2e6b16146effa5abf66cc2af12a6d819@jays.net> Huh. I think I just coded my first hash slice in the wild (the 'my $key =' line). I blame Andy Lester for posting array slices last year. Is this code evil? while (my $href = $sth->fetchrow_hashref) { foreach my $key (keys %$href) { $href->{$key} =~ s/\s+$//; } $DB::single = 1; my $key = join "|", @$href{ qw(rate_cat room_code hrms_room_cat stod etod) }; print "$key\n"; unless ($self->_Band2s->{$key}) { my $b2 = Omni2::Control::OmniCRS::HRMS::Band2->new($href); $self->_Band2s->{$key} = $b2; } } In the debugger, below... Ponder, j 78: my $key = join "|", @$href{ qw(rate_cat room_code hrms_room_cat stod etod) }; DB<2> x $href 0 HASH(0x8d8d3cc) 'accepted_len_stay' => 'YYYYYYY' 'break_point' => 109 'current' => 'N' 'etod' => 1600 'hrms_room_cat' => 'DELUXE' 'length_of_stay' => 'YYYYYYY' 'rate_cat' => 'CR' 'room_code' => 5637 'stod' => 1200 DB<3> n Omni2::Control::OmniCRS::HRMS::Band1::load_from_omni_crs(/home/jhannah/src/Omni2/Control/OmniCRS/HRMS/Band1.pm:79): 79: print "$key\n"; DB<3> n CR|5637|DELUXE|1200|1600 From andy at petdance.com Wed Oct 1 12:48:25 2008 From: andy at petdance.com (Andy Lester) Date: Wed, 1 Oct 2008 14:48:25 -0500 Subject: [Omaha.pm] My first hash slice In-Reply-To: <2e6b16146effa5abf66cc2af12a6d819@jays.net> References: <2e6b16146effa5abf66cc2af12a6d819@jays.net> Message-ID: On Oct 1, 2008, at 2:34 PM, wrote: > while (my $href = $sth->fetchrow_hashref) { > foreach my $key (keys %$href) { > $href->{$key} =~ s/\s+$//; > } > $DB::single = 1; > my $key = join "|", @$href{ qw(rate_cat room_code hrms_room_cat > stod > etod) }; > print "$key\n"; > unless ($self->_Band2s->{$key}) { > my $b2 = Omni2::Control::OmniCRS::HRMS::Band2->new($href); > $self->_Band2s->{$key} = $b2; > } > } Now, note that you have a $key in the foreach loop, AND you're overriding it inside the loop, too. That's confusing. Also, how about instead of print "$key\n"; you use say $key; xoxo, andy -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From jay at jays.net Thu Oct 2 06:02:28 2008 From: jay at jays.net (Jay Hannah) Date: Thu, 2 Oct 2008 08:02:28 -0500 Subject: [Omaha.pm] My first hash slice In-Reply-To: References: <2e6b16146effa5abf66cc2af12a6d819@jays.net> Message-ID: <1701CA17-BDCF-42BA-BAFD-413BE752B04D@jays.net> On Oct 1, 2008, at 2:34 PM, wrote: > while (my $href = $sth->fetchrow_hashref) { > foreach my $key (keys %$href) { > $href->{$key} =~ s/\s+$//; > } > $DB::single = 1; > my $key = join "|", @$href{ qw(rate_cat room_code > hrms_room_cat stod etod) }; > print "$key\n"; > unless ($self->_Band2s->{$key}) { > my $b2 = Omni2::Control::OmniCRS::HRMS::Band2->new($href); > $self->_Band2s->{$key} = $b2; > } > } On Oct 1, 2008, at 2:48 PM, Andy Lester wrote: > Now, note that you have a $key in the foreach loop, AND you're > overriding it inside the loop, too. That's confusing. Ya. That first $key is throwaway. Only used for 1 line of code. I'm thinking changing the second $key to some other variable name would lead a reader to believe that I still care about the first $key, which I don't. Would this be better or worse? map { $href->{$_} =~ s/\s+$// } keys %$href; Worse, I suspect. Or for (values %$href) { s/\s+$// } Looks like those both work. I'm thinking the last one is best. > Also, how about instead of > > print "$key\n"; > > you use > > say $key; That's a 5.10 feature, yes? We're not a 5.10 shop yet. Thanks, j From jhannah at omnihotels.com Thu Oct 2 09:33:34 2008 From: jhannah at omnihotels.com (Jay Hannah) Date: Thu, 2 Oct 2008 11:33:34 -0500 Subject: [Omaha.pm] Moose commit bit Message-ID: <396CEDAA86B38646ACE2FEAA22C3FBF111DD3D@l3exchange.omnihotels.net> Sweet, I have a Moose commit bit too now. Below, my first patch. A stroke of genius, wouldn't you say? :) j $ svn diff -r6239:6240 Index: lib/Moose/Util/TypeConstraints.pm =================================================================== --- lib/Moose/Util/TypeConstraints.pm (revision 6239) +++ lib/Moose/Util/TypeConstraints.pm (revision 6240) @@ -751,7 +751,7 @@ B Any type followed by a type parameter C<[`a]> can be parameterized, this means you can say: - ArrayRef[Int] # an array of intergers + ArrayRef[Int] # an array of integers HashRef[CodeRef] # a hash of str to CODE ref mappings Maybe[Str] # value may be a string, may be undefined $ svn log -vr6240 ------------------------------------------------------------------------ r6240 | jhannah | 2008-10-02 11:28:04 -0500 (Thu, 02 Oct 2008) | 2 lines Changed paths: M /Moose/trunk/lib/Moose/Util/TypeConstraints.pm POD typo corrected. ------------------------------------------------------------------------ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Sun Oct 12 06:03:55 2008 From: jay at jays.net (Jay Hannah) Date: Sun, 12 Oct 2008 08:03:55 -0500 Subject: [Omaha.pm] Meeting Tue Oct. 14 References: <65F96DC8-45A9-4CB4-93AE-6ADA613AE4E9@gmail.com> Message-ID: <7EC80115-9A70-4CD3-B715-EAE751B3C4E9@jays.net> Howdy, fellow Perl Mongers. Here's some info on our next meeting, coming up this Tuesday. Hope to see you there. :) j Omaha Perl Mongers: http://omaha.pm.org Begin forwarded message: > From: Samuel Tesla > Date: October 11, 2008 5:10:10 PM CDT > To: odynug at googlegroups.com > Subject: [odynug] Shifting gears for Tuesday > Reply-To: odynug at googlegroups.com > > > Hey all! > > I'm going to be talking next Tuesday about advanced Erlang. As I > mentioned a while back, my plan was to write a blogging tool in Erlang > and then discuss the architecture and code. Between my work and my > 3/4- > time class load at UNO, I really haven't managed to devote much time > to writing the tool. I want to show a good example of how erlang apps > get put together, so I'm going to be talking about another project. > > Ejabberd is a stable, production-quality XMPP server written erlang. > It's the server used by jabber.org and the IETF for their XMPP > services. Along with YAWS, and RabbitMQ it is one of the biggest > open- > source erlang projects out there. > > I'll see everybody on Tuesday! > > -- Samuel > From jay at jays.net Mon Oct 20 12:55:48 2008 From: jay at jays.net (Jay Hannah) Date: Mon, 20 Oct 2008 14:55:48 -0500 Subject: [Omaha.pm] CORE::length Message-ID: <25F3DAE5-3B29-421C-9DB4-9EB8067421DC@jays.net> Below, the svn annotate and log of a change I didn't understand to BioPerl. ===================================================== 2705 matsallac sub validate_qual { 4015 jason # how do I validate quality values? 4015 jason # \d+\s+\d+..., I suppose 4015 jason my ($self,$qualstr) = @_; 4015 jason # why the CORE?? -- (Because Bio::PrimarySeqI namespace has a 4015 jason # length method, you have to qualify 4015 jason # which length to use) 4015 jason return 0 if (!defined $qualstr || CORE::length ($qualstr) <= 0); 4015 jason return 1 if( $qualstr =~ /\d/); 4015 jason 4015 jason return 0; 2705 matsallac } jhannah at klab:~/src/bioperl-live$ svn log -vr4015 ------------------------------------------------------------------------ r4015 | jason | 2002-05-30 16:38:18 -0500 (Thu, 30 May 2002) | 2 lines Changed paths: M /bioperl-live/trunk/Bio/Seq/PrimaryQual.pm prettier, less chatty code - better logic for setting qual() data ------------------------------------------------------------------------ ===================================================== Perhaps back in 2002 Perls length() was ambiguous, but in Perl 5.8.8 I can't get it to break no matter what I try. ===================================================== package ONE; sub length { die }; package TWO; use base ONE; sub new { return bless {} }; sub length { die }; package main; my $two = TWO->new(); print length("xxxxxxxx"); sub length { die }; ===================================================== So I guess I can go back to never worrying about or using CORE:: (a reserved Perl namespace, apparently)... j From jay at jays.net Mon Oct 20 13:01:34 2008 From: jay at jays.net (Jay Hannah) Date: Mon, 20 Oct 2008 15:01:34 -0500 Subject: [Omaha.pm] CORE::length In-Reply-To: <25F3DAE5-3B29-421C-9DB4-9EB8067421DC@jays.net> References: <25F3DAE5-3B29-421C-9DB4-9EB8067421DC@jays.net> Message-ID: On Oct 20, 2008, at 2:55 PM, Jay Hannah wrote: > Perhaps back in 2002 Perls length() was ambiguous ... if you have a local or inherited sub length { }. j From jay at jays.net Sat Oct 25 05:37:05 2008 From: jay at jays.net (Jay Hannah) Date: Sat, 25 Oct 2008 07:37:05 -0500 Subject: [Omaha.pm] Some lines of a file References: <4900A2BC.2050705@jays.net> Message-ID: <452FE497-C7EA-4683-B1E0-DE30936CFCC2@jays.net> A friend of mine asked me for this one yesterday. Problem: Given STDIN print everything except the first 2 lines and last 4 lines. Solution: while (<>) { push @in, $_; } print splice(@in, 2, @in - 6); Note this is a terrible solution with large files (memory hog), but works fine on small STDIN. Cheers, j $ cat j one two three four five six seven eight nine ten $ cat j | perl j2.pl three four five six From jay at jays.net Sat Oct 25 05:40:40 2008 From: jay at jays.net (Jay Hannah) Date: Sat, 25 Oct 2008 07:40:40 -0500 Subject: [Omaha.pm] BioNerdery, a year in the life Message-ID: <397A0B43-4D51-40B3-A900-CC7E7587EBAB@jays.net> -ponder- I guess this "Integration Candidates" page I made yesterday is sort of a list of possibly general use tools I've worked on over the last year: http://clab.ist.unomaha.edu/CLAB/index.php/BioCMS (RT username: guest, password: guest) It's all Perl, and we could always use more volunteer help. If you're interested in medical research with Perl let me know. :) j From robert.fulkerson at gmail.com Sat Oct 25 17:50:45 2008 From: robert.fulkerson at gmail.com (Robert Fulkerson) Date: Sat, 25 Oct 2008 19:50:45 -0500 Subject: [Omaha.pm] Some lines of a file In-Reply-To: <452FE497-C7EA-4683-B1E0-DE30936CFCC2@jays.net> References: <4900A2BC.2050705@jays.net> <452FE497-C7EA-4683-B1E0-DE30936CFCC2@jays.net> Message-ID: <6cb6eebc0810251750n680aa42br368137ed1b47c93d@mail.gmail.com> Y'know, I should be grabbing some of these ideas for quiz and exam questions. :) That's certainly the oddball kind of thing one of us goofball instructors would ask on an exam. ;) -- b On Sat, Oct 25, 2008 at 7:37 AM, Jay Hannah wrote: > A friend of mine asked me for this one yesterday. > > > Problem: > > Given STDIN print everything except the first 2 lines and last 4 lines. > > > Solution: > > while (<>) { > push @in, $_; > } > print splice(@in, 2, @in - 6); > > > Note this is a terrible solution with large files (memory hog), but works > fine on small STDIN. > > Cheers, > > j > > > > $ cat j > one > two > three > four > five > six > seven > eight > nine > ten > $ cat j | perl j2.pl > three > four > five > six > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm at pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay at jays.net Sat Oct 25 19:06:32 2008 From: jay at jays.net (Jay Hannah) Date: Sat, 25 Oct 2008 21:06:32 -0500 Subject: [Omaha.pm] Some lines of a file In-Reply-To: <6cb6eebc0810251750n680aa42br368137ed1b47c93d@mail.gmail.com> References: <4900A2BC.2050705@jays.net> <452FE497-C7EA-4683-B1E0-DE30936CFCC2@jays.net> <6cb6eebc0810251750n680aa42br368137ed1b47c93d@mail.gmail.com> Message-ID: <75C18414-BD78-412E-AE96-973104CD6960@jays.net> On Oct 25, 2008, at 7:50 PM, Robert Fulkerson wrote: > Y'know, I should be grabbing some of these ideas for quiz and exam > questions. :) That's certainly the oddball kind of thing one of > us goofball instructors would ask on an exam. ;) Our mail archive might help. :) http://mail.pm.org/pipermail/omaha-pm/ Or this? http://perl101.org/ j From jhannah at omnihotels.com Thu Oct 30 14:32:59 2008 From: jhannah at omnihotels.com (Jay Hannah) Date: Thu, 30 Oct 2008 16:32:59 -0500 Subject: [Omaha.pm] blank line here-doc Message-ID: <396CEDAA86B38646ACE2FEAA22C3FBF1EDB9F0@l3exchange.omnihotels.net> Oh, that's a cute trick. I've never seen a here-doc based on a blank line before. (From Catalyst::Engine::finalize_error().) $c->res->body( <<"" ); blah1 blah2 blah3 # Trick IE $c->res->{body} .= ( ' ' x 512 ); More on here-docs: http://www.devfaq.net/index.php?act=faq&id=620 Cheers, j -------------- next part -------------- An HTML attachment was scrubbed... URL: From jharr at ist.unomaha.edu Fri Oct 31 08:45:36 2008 From: jharr at ist.unomaha.edu (James Harr) Date: Fri, 31 Oct 2008 10:45:36 -0500 Subject: [Omaha.pm] Some lines of a file In-Reply-To: <6cb6eebc0810251750n680aa42br368137ed1b47c93d@mail.gmail.com> References: <4900A2BC.2050705@jays.net><452FE497-C7EA-4683-B1E0-DE30936CFCC2@jays.net> <6cb6eebc0810251750n680aa42br368137ed1b47c93d@mail.gmail.com> Message-ID: Sticking with the tradition of timtowtdi: @in = <>; print splice(@in, 2, @in - 6); ... or ... <> foreach 0 .. 1; push @buf, scalar(<>) foreach 0 .. 5; while(<>) { push @buf, $_; print shift @buf; } ... continuing on the path to insanity through inverted loops ... <> foreach 0 .. 1; push @buf, scalar(<>) foreach 0 .. 5; sub {push @buf, $_; print shift @buf}->() while <>; I shouldn't be allowed to code perl. http://forums.somethingawful.com/showthread.php?threadid=2952520 - Programming languages personified, see perl (I'd have ad-block if I were you). ------------------- From: omaha-pm-bounces+jharr=ist.unomaha.edu at pm.org [mailto:omaha-pm-bounces+jharr=ist.unomaha.edu at pm.org] On Behalf Of Robert Fulkerson Sent: Saturday, October 25, 2008 19:51 To: Perl Mongers of Omaha, Nebraska USA Subject: Re: [Omaha.pm] Some lines of a file Y'know, I should be grabbing some of these ideas for quiz and exam questions. ?:) ?That's certainly the oddball kind of thing one of us goofball instructors would ask on an exam. ?;) -- b On Sat, Oct 25, 2008 at 7:37 AM, Jay Hannah wrote: A friend of mine asked me for this one yesterday. Problem: ?Given STDIN print everything except the first 2 lines and last 4 lines. Solution: ?while (<>) { ? ? push @in, $_; ?} ?print splice(@in, 2, @in - 6); Note this is a terrible solution with large files (memory hog), but works fine on small STDIN. Cheers, j $ cat j one two three four five six seven eight nine ten $ cat j | perl j2.pl three four five six _______________________________________________ Omaha-pm mailing list Omaha-pm at pm.org http://mail.pm.org/mailman/listinfo/omaha-pm From jay at jays.net Fri Oct 31 09:25:44 2008 From: jay at jays.net (Jay Hannah) Date: Fri, 31 Oct 2008 11:25:44 -0500 Subject: [Omaha.pm] Some lines of a file In-Reply-To: References: <4900A2BC.2050705@jays.net><452FE497-C7EA-4683-B1E0-DE30936CFCC2@jays.net> <6cb6eebc0810251750n680aa42br368137ed1b47c93d@mail.gmail.com> Message-ID: <490B3188.1090501@jays.net> James Harr wrote: > ... continuing on the path to insanity through inverted loops ... > > <> foreach 0 .. 1; > push @buf, scalar(<>) foreach 0 .. 5; > sub {push @buf, $_; print shift @buf}->() while <>; > > I shouldn't be allowed to code perl. > Laugh! Reverse Perl golf! Longer and harder to read! ;) Thanks for @in = <>; I like that better than my 3 line version. :) j From jay at jays.net Fri Oct 31 11:46:21 2008 From: jay at jays.net (Jay Hannah) Date: Fri, 31 Oct 2008 13:46:21 -0500 Subject: [Omaha.pm] EditGrid - online spreadsheets (Catalyst) Message-ID: <490B527D.2040402@jays.net> Wow. This whole thing is just HTML and Javascript: http://www.editgrid.com/ And Catalyst is the framework. Fancy pantsy, :) j