From rjbs-perl-abe at lists.manxome.org Fri Jun 1 06:34:51 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Fri, 1 Jun 2007 09:34:51 -0400 Subject: [ABE.pm] stupid perl bugs^Wtricks Message-ID: <20070601133451.GA23747@knight.manxome.org> A bug was recently found in perl. This isn't tremendously exciting, but the bug itself is cute, and I thought I'd share it with you. Hopefully you all know about "my" and global variables. "my" (or "lexical") variables only exist as long as the block in which they were declared lasts. (I'm simplifying that, but you get the point.) Global variables are accessible anywhere, and can be declared, more or less, with "use vars" or "our" or just by using their fully-qualified name. "local" is a mechanism for doing "dynamic scoping." It means that you can say, "I am replacing this global variable with a localized variable of the same name, and anything below me in the call stack will see its value, not the current one." So, you can do this: our $VERSION = 10; sub say_version { print "$VERSION\n" } sub lie_about_version { my $lie = shift; local $VERSION = $lie; say_version; } lie_about_version(11); ...and even though the "11" isn't passed in to say_version, it prints 11. The value of the global $VERSION has been localized. If say_version called something else, THAT would see 11, too. The original value of 10 would be restored when lie_about_version's call returned. If you already knew about local, what you might not have known is that you can localize not just global variables, but also hash entries on lexical hashes. What do I mean? Well: my $datum = { version => 10, flavor => 'sassafras', }; sub say_version { my ($datum) = @_; print "$datum->{version}\n"; } sub lie_about_version { my ($datum, $lie) = @_; local $datum->{version} = $lie; say_version($datum); } lie_about_version($datum, 11); It does the same thing! The one entry on the hash is localized, and gets restored when the localing block returns/ends. This can be really useful to subtly tweak data that's being passed around without actually altering it. Here's the bug: my %hash = (foo => 1); { my $key = 'foo'; local $hash{ $key } = 2; $key = 'bar'; } print Dumper(\%hash); You'd expect it to look just like it did before, right? But no! $VAR1 = { 'bar' => 1, 'foo' => 2 }; The localization remembers that "I localized whatever is in $key on %hash," so that when it delocalizes, it restores the OLD hash entry value to the NEW value from $key. Neat bug! How important is this bug? Well, apparently it was introduced in 1998 or so and nobody noticed until last week. Probably not very important... just neat! -- rjbs From faber at linuxnj.com Fri Jun 1 09:25:22 2007 From: faber at linuxnj.com (Faber J. Fedor) Date: Fri, 1 Jun 2007 12:25:22 -0400 Subject: [ABE.pm] Is this safe coding practice? Message-ID: <20070601162522.GA770@neptune.faber.nom> I don't think this is what Larry, et. al had in mind when they wrote the parameter passing routines in Perl, but this works for me. I'm just wondering if there are any hidden gotchas: I've got a func that returns the min and max values in an array: sub getMinMax { my @data = @_ ; my $stat = Statistics::Descriptive::Full->new(); # a great stats package! $stat->add_data(@data); return ($stat->min(), $stat->max()); } and of course, this works fine: ($MinY, $MaxY) = getMinMax(@foo); Is there anything wrong with calling it like this as well: ($MinY, $MaxY) = getMinMax(@foo, @bar); or even as ($MinY, $MaxY) = getMinMax(@foo, @bar, $fubar); assuming you want the min and max values of all the data in @foo, @bar and $fubar? AFAICT, it works, but it doesn't seem to be "proper", i.e. you can do that but you shouldn't do that. -- Regards, Faber Fedor President Linux New Jersey, Inc. 908-320-0357 800-706-0701 http://www.linuxnj.com From john-abe at apt202.net Fri Jun 1 09:50:16 2007 From: john-abe at apt202.net (John Cappiello) Date: Fri, 1 Jun 2007 12:50:16 -0400 Subject: [ABE.pm] Is this safe coding practice? In-Reply-To: <20070601162522.GA770@neptune.faber.nom> References: <20070601162522.GA770@neptune.faber.nom> Message-ID: <20070601165016.GE3117@apt202.net> On Fri, Jun 01, 2007 at 12:25:22PM -0400, Faber J. Fedor wrote: > and of course, this works fine: > ($MinY, $MaxY) = getMinMax(@foo); > > Is there anything wrong with calling it like this as well: > ($MinY, $MaxY) = getMinMax(@foo, @bar); > > or even as > ($MinY, $MaxY) = getMinMax(@foo, @bar, $fubar); These all look fine to me within reason. It all comes down to readability. Will you be able to look at this in three months and get it? I'm pretty sure they had things just like this in mind when they designed it. -- jcap From faber at linuxnj.com Fri Jun 1 09:57:56 2007 From: faber at linuxnj.com (Faber Fedor) Date: Fri, 1 Jun 2007 12:57:56 -0400 Subject: [ABE.pm] Is this safe coding practice? In-Reply-To: <20070601165016.GE3117@apt202.net> References: <20070601162522.GA770@neptune.faber.nom> <20070601165016.GE3117@apt202.net> Message-ID: <300ccfa50706010957n16947974n62f09a1a31608579@mail.gmail.com> On 6/1/07, John Cappiello wrote: > These all look fine to me within reason. It all comes down to > readability. Will you be able to look at this in three months and get > it? That's what comments are for. I'm pretty sure they had things just like this in mind when they > designed it. That's just sick! :-) -- Faber -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070601/f436735b/attachment.html From john-abe at apt202.net Fri Jun 1 10:04:22 2007 From: john-abe at apt202.net (John Cappiello) Date: Fri, 1 Jun 2007 13:04:22 -0400 Subject: [ABE.pm] Is this safe coding practice? In-Reply-To: <300ccfa50706010957n16947974n62f09a1a31608579@mail.gmail.com> References: <20070601162522.GA770@neptune.faber.nom> <20070601165016.GE3117@apt202.net> <300ccfa50706010957n16947974n62f09a1a31608579@mail.gmail.com> Message-ID: <20070601170422.GF3117@apt202.net> On Fri, Jun 01, 2007 at 12:57:56PM -0400, Faber Fedor wrote: > That's what comments are for. Comments are no excuse for unintelligible code. -- jcap From rjbs-perl-abe at lists.manxome.org Fri Jun 1 11:21:36 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Fri, 1 Jun 2007 14:21:36 -0400 Subject: [ABE.pm] Is this safe coding practice? In-Reply-To: <20070601162522.GA770@neptune.faber.nom> References: <20070601162522.GA770@neptune.faber.nom> Message-ID: <20070601182136.GA24199@knight.manxome.org> * "Faber J. Fedor" [2007-06-01T12:25:22] > I don't think this is what Larry, et. al had in mind when they wrote the > parameter passing routines in Perl, but this works for me. I'm just > wondering if there are any hidden gotchas: I think you're wrong. ;) The things you're talking about have a lot to do with the kind of list flattening, stack passing parameter style in Perl 5. I don't know Larry's intent, but I think that you think this is a bad idea on levels on which it isn't... > I've got a func that returns the min and max values in an array: Nitpick: subroutines never return arrays. They return scalars or lists. A list is an immutable sequence of data, an array is a container that holds a mutable sequence. This doesn't usually matter, but get used to thinking about it correctly, and someday you will not make a mistake that you might have otherwise made. > ($MinY, $MaxY) = getMinMax(@foo); > ($MinY, $MaxY) = getMinMax(@foo, @bar); > ($MinY, $MaxY) = getMinMax(@foo, @bar, $fubar); > > assuming you want the min and max values of all the data in @foo, @bar > and $fubar? These seem absolutely dandy. Here's the thing, though. I would probably pass a reference in, for two reasons: First, if you're most often passing in one array, you save memory by not copying it here. (If you are passing many, you will have to construct a new array to reference, so that savings is gone.) Secondly, it leaves you open to future expansion of your semantics. See, if you say, now, "get_min_max takes a list of data to minmax" then you can never, ever change the specifics, because you can't add more parameters: any parameter you add is by definition part of the list of data. There are two solutions: (1) Later, declare that some sort of datum is magic in the last value (well, if the last value is a hashref, it's actually options), but this can be a real pain in the butt. (2) Always pass in an arrayref, therefore creating a definition for the semantics of only one parameter. Later, you can say that the second param modifies the routine's behavior in some way. -- rjbs From faber at linuxnj.com Fri Jun 1 14:40:04 2007 From: faber at linuxnj.com (Faber Fedor) Date: Fri, 1 Jun 2007 17:40:04 -0400 Subject: [ABE.pm] Travel plans? In-Reply-To: <20070601034811.GA23018@knight.manxome.org> References: <20070531182231.GA30829@neptune.faber.nom> <20070531183449.GA30115@apt202.net> <300ccfa50705312033h381a2d9bo1a9fca6b4db8c46a@mail.gmail.com> <20070601034811.GA23018@knight.manxome.org> Message-ID: <300ccfa50706011440s3c602620x6b717366862e3823@mail.gmail.com> How does one know what their userid number is for the wiki page? On 5/31/07, Ricardo SIGNES wrote: > > * Faber Fedor [2007-05-31T23:33:40] > > What time/day are you guys leaving? I was thinking of heading down a > few > > days early (Fri., Sat.) to hang out and see Houston. > > http://conferences.mongueurs.net/yn2007/wiki?node=Departures%20by%20air > > -- > rjbs > _______________________________________________ > ABE-pm mailing list > ABE-pm at pm.org > http://mail.pm.org/mailman/listinfo/abe-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070601/e726f2c8/attachment.html From rjbs-perl-abe at lists.manxome.org Fri Jun 1 15:12:54 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Fri, 1 Jun 2007 18:12:54 -0400 Subject: [ABE.pm] Travel plans? In-Reply-To: <300ccfa50706011440s3c602620x6b717366862e3823@mail.gmail.com> References: <20070531182231.GA30829@neptune.faber.nom> <20070531183449.GA30115@apt202.net> <300ccfa50705312033h381a2d9bo1a9fca6b4db8c46a@mail.gmail.com> <20070601034811.GA23018@knight.manxome.org> <300ccfa50706011440s3c602620x6b717366862e3823@mail.gmail.com> Message-ID: <20070601221254.GA24709@knight.manxome.org> * Faber Fedor [2007-06-01T17:40:04] > How does one know what their userid number is for the wiki page? Man, I @#$@#$ing hate that wiki. Hover over the link to your profile on the left sidebar. -- rjbs From faber at linuxnj.com Fri Jun 1 15:37:01 2007 From: faber at linuxnj.com (Faber Fedor) Date: Fri, 1 Jun 2007 18:37:01 -0400 Subject: [ABE.pm] Is this safe coding practice? In-Reply-To: <20070601182136.GA24199@knight.manxome.org> References: <20070601162522.GA770@neptune.faber.nom> <20070601182136.GA24199@knight.manxome.org> Message-ID: <300ccfa50706011537o5412f804r9c7ff09b9a89d878@mail.gmail.com> On 6/1/07, Ricardo SIGNES wrote: > > * "Faber J. Fedor" [2007-06-01T12:25:22] > > I don't think this is what Larry, et. al had in mind when they wrote the > > parameter passing routines in Perl, but this works for me. I'm just > > wondering if there are any hidden gotchas: > > I think you're wrong. ;) The things you're talking about have a lot to do > with > the kind of list flattening, stack passing parameter style in Perl 5. > > I don't know Larry's intent, but I think that you think this is a bad idea > on > levels on which it isn't... Au contrair! I deduced that it would work from basic principles ("If Perl flattens it the way I understand it, then this will work...") and thought it Way Cool when it did. However, since I haven't seen that idiom anywhere, I assumed there was a Rule Against It. > I've got a func that returns the min and max values in an array: > > Nitpick: subroutines never return arrays. They return scalars or > lists. A > list is an immutable sequence of data, an array is a container that holds > a > mutable sequence. Which is why I can't do (@MinY, @MaxY) = getMinMax(@foo) because Perl can't tell where to split the arrays I'm returning, right? get used to thinking about > it correctly, and someday you will not make a mistake that you might have > otherwise made. I don't need that lecture, you whippersnapper! :-) it's one of my guiding principles and something I impress on my students. Here's the thing, though. I would probably pass a reference in, I prolly would too, but this was a serendiptous discovery during refactoring. See, if you say, now, "get_min_max takes a list of data to minmax" then you > can > never, ever change the specifics, because you can't add more > parameters: any > parameter you add is by definition part of the list of data. > > There are two solutions: (1) Later, declare that some sort of datum is > magic in > the last value (well, if the last value is a hashref, it's actually > options), > but this can be a real pain in the butt. and it's tacky, too! (2) Always pass in an arrayref, > therefore creating a definition for the semantics of only one parameter. > Later, you can say that the second param modifies the routine's behavior > in > some way. Then I don't grok the technique here. If I modified my original code to use an array ref, the code would look like this: sub getMinMax { my ($data) = @_ ; my $stat = Statistics::Descriptive::Full->new(); # a great stats package! $stat->add_data(@$data); return ($stat->min(), $stat->max()); } I don't see how to get/use a second parameter in the arrayref. -- Faber -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070601/94b474da/attachment.html From faber at linuxnj.com Fri Jun 1 15:46:07 2007 From: faber at linuxnj.com (Faber Fedor) Date: Fri, 1 Jun 2007 18:46:07 -0400 Subject: [ABE.pm] Travel plans? In-Reply-To: <20070531183449.GA30115@apt202.net> References: <20070531182231.GA30829@neptune.faber.nom> <20070531183449.GA30115@apt202.net> Message-ID: <300ccfa50706011546s2701070pd95c0b3d53126ff3@mail.gmail.com> On 5/31/07, John Cappiello wrote: > > On Thu, May 31, 2007 at 02:22:31PM -0400, Faber J. Fedor wrote: > > Ideas? > > You could come park at my place in East Falls (NW PHL) and we can take > the train down together. Maybe $10 round trip on the train. 30mins > each way. How about I show up on Saturday and you put me on the train? -- Faber -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070601/4e84b98a/attachment.html From john-abe at apt202.net Fri Jun 1 16:27:42 2007 From: john-abe at apt202.net (John Cappiello) Date: Fri, 1 Jun 2007 19:27:42 -0400 Subject: [ABE.pm] Travel plans? In-Reply-To: <300ccfa50706011546s2701070pd95c0b3d53126ff3@mail.gmail.com> References: <20070531182231.GA30829@neptune.faber.nom> <20070531183449.GA30115@apt202.net> <300ccfa50706011546s2701070pd95c0b3d53126ff3@mail.gmail.com> Message-ID: <20070601232742.GA13492@apt202.net> On Fri, Jun 01, 2007 at 06:46:07PM -0400, Faber Fedor wrote: > How about I show up on Saturday and you put me on the train? Sure thing. Just make sure you have my contact info ahead of time. -- jcap From faber at linuxnj.com Fri Jun 1 16:36:32 2007 From: faber at linuxnj.com (Faber Fedor) Date: Fri, 1 Jun 2007 19:36:32 -0400 Subject: [ABE.pm] Travel plans? In-Reply-To: <20070601232742.GA13492@apt202.net> References: <20070531182231.GA30829@neptune.faber.nom> <20070531183449.GA30115@apt202.net> <300ccfa50706011546s2701070pd95c0b3d53126ff3@mail.gmail.com> <20070601232742.GA13492@apt202.net> Message-ID: <300ccfa50706011636g1c7896d9w4371d653ebb03b13@mail.gmail.com> On 6/1/07, John Cappiello wrote: > > On Fri, Jun 01, 2007 at 06:46:07PM -0400, Faber Fedor wrote: > > How about I show up on Saturday and you put me on the train? > > Sure thing. Just make sure you have my contact info ahead of time. Should I divine is psychically or do you want to send it to me? :-) -- Faber -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070601/1bd785b5/attachment.html From rjbs-perl-abe at lists.manxome.org Fri Jun 1 16:48:37 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Fri, 1 Jun 2007 19:48:37 -0400 Subject: [ABE.pm] Is this safe coding practice? In-Reply-To: <300ccfa50706011537o5412f804r9c7ff09b9a89d878@mail.gmail.com> References: <20070601162522.GA770@neptune.faber.nom> <20070601182136.GA24199@knight.manxome.org> <300ccfa50706011537o5412f804r9c7ff09b9a89d878@mail.gmail.com> Message-ID: <20070601234837.GA24846@knight.manxome.org> * Faber Fedor [2007-06-01T18:37:01] > >I've got a func that returns the min and max values in an array: > > > >Nitpick: subroutines never return arrays. They return scalars or lists. A > >list is an immutable sequence of data, an array is a container that holds a > >mutable sequence. > > (@MinY, @MaxY) = getMinMax(@foo) > > because Perl can't tell where to split the arrays I'm returning, right? Right. > >it correctly, and someday you will not make a mistake that you might have > >otherwise made. > > I don't need that lecture, you whippersnapper! :-) it's one of my guiding > principles and something I impress on my students. Sorry, gramps! > Then I don't grok the technique here. If I modified my original code to use > an array ref, the code would look like this: > > sub getMinMax { > my ($data) = @_ ; > my $stat = Statistics::Descriptive::Full->new(); > $stat->add_data(@$data); > return ($stat->min(), $stat->max()); > } > > I don't see how to get/use a second parameter in the arrayref. Not in the arrayref, but after it: sub getMinMax { my ($data, $arg) = @_ ; my $stat = Statistics::Descriptive::Full->new; $stat->pre_sorted(1) if $arg->{pre_sorted}; $stat->add_data(@$data); return ($stat->min, $stat->max); } -- rjbs From rjbs-perl-abe at lists.manxome.org Sun Jun 3 16:59:15 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Sun, 3 Jun 2007 19:59:15 -0400 Subject: [ABE.pm] dinner, june 6 In-Reply-To: <20070530093053.GB32323@zodiac.codesimply.com> References: <20070530093053.GB32323@zodiac.codesimply.com> Message-ID: <20070603235915.GA30461@zodiac.codesimply.com> * Ricardo SIGNES [2007-05-30T05:30:53] > One week from today is the first Wednesday of the month. Mach's Gute? 18:00 too early? Works for me... you all? -- rjbs From rjbs-perl-abe at lists.manxome.org Sun Jun 3 17:29:22 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Sun, 3 Jun 2007 20:29:22 -0400 Subject: [ABE.pm] perl 5.10 rules! - a switch statement Message-ID: <20070604002922.GB30461@zodiac.codesimply.com> Holy crap, the pigs just flew in from Hell, which had frozen over. Perl is getting a "switch" statement... but there's a twist. Some languages have a statement that works like this: switch (variable) { case 1: do_something_one; break; case 2: do_something_2; break; default: do_default; } It does just what you think. I've left out the nuances that you probably know about: leaving out 'break' to fall through or having multiple sequential cases to let one bunch of code handle multiple cases. In Perl, this sort of thing is really easy to do with a hash, using a dispatch: %dispatch = ( 1 => \&do_something_one, 2 => \&do_something_2, default => \&do_default; ); $handler = $dispatch{ $variable } || $dispatch{ default }; $handler->(); So, when people clamor for a switch statement, the traditional response has been, "Jeez, people. Write Perl, not C." Why, then, is one being added? Because it's way, way more powerful than a C switch statement, and a mere dispatch table wouldn't work. With a name stolen from Perl 6, it's called "given." Our boring switch/dispatch from above would be: given ($variable) { when (1) { do_something_one; } # if $variable == 1 when (2) { do_something_2; } # if $variable == 2 default { do_default; } } ...but how about some additional awesome magic? given ($variable) { when (1) { # $variable == 1 do_something_one; } when (@edge_cases) { # if $variable in @edge_cases do_edge_case_handler; } when ($_ > 10e6) { # if $variable is over a million do_huge_handler; } when (\&test) { # if test($_) is true say "the test was true!"; continue; } default { default_handler; } } Woah! There's magic for all manner of when check, and they all pretty much make sense. Want to know what's cooler? You can use them outside of a given/when structure. Let's say you used to say something like: die "We don't support your browser!" if $user_agent eq $unsupported_browser; ...then later you actually have a bunch of browsers you don't work on, so you start passing in an aarrayref instead of a string: die "We don't support your browser!" if grep { $user_agent eq $_ } @$unsupported_browser; ...and then finally you're reduced to passing in a subref that does a lookup based on the latest user-agent strings known: die "We don't support your browser!" if $unsupported_browser->($user_agent); In 5.10, you could have solved this problem at the outside by writing: die "We don't support your browser!" if $user_agent ~~ $unsupported_browser; When you started out, you'd have put a string in there, and it would use eq. Later, you'd put in an arrayref, and it would check whether $user_agent was in the arrayref. Finally, you'd put in a coderef and it would call it. By saying that something is a "smart match" target, rather than something more specific, you can make your code very flexible without writing a lot of polymorphism on your own. The full table of how ~~ works can be found in perl 5.9.5's perlsyn page: http://search.cpan.org/~rgarcia/perl/pod/perlsyn.pod#Smart_matching_in_detail -- rjbs From fiedlert at gmail.com Mon Jun 4 04:30:04 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Mon, 4 Jun 2007 07:30:04 -0400 Subject: [ABE.pm] dinner, june 6 In-Reply-To: <20070603235915.GA30461@zodiac.codesimply.com> References: <20070530093053.GB32323@zodiac.codesimply.com> <20070603235915.GA30461@zodiac.codesimply.com> Message-ID: <814422ce0706040430l2a7ec386g639d322ebe74e988@mail.gmail.com> I gotta bag it this month - I was hoping to make it, but I just have TOO much work to do both for the $job and @ the new house. Being your own landscaper is a rough proposition. See y'all next month... Ted On 6/3/07, Ricardo SIGNES wrote: > > * Ricardo SIGNES [2007-05-30T05:30:53] > > One week from today is the first Wednesday of the month. Mach's Gute? > > 18:00 too early? Works for me... you all? > > -- > rjbs > _______________________________________________ > ABE-pm mailing list > ABE-pm at pm.org > http://mail.pm.org/mailman/listinfo/abe-pm > -- "You are never dedicated to something you have complete confidence in. No one is fanatically shouting that the sun is going to rise tomorrow. They know it's going to rise tomorrow. " -- Robert M Pirsig -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070604/00953036/attachment.html From fiedlert at gmail.com Mon Jun 4 04:36:09 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Mon, 4 Jun 2007 07:36:09 -0400 Subject: [ABE.pm] perl 5.10 rules! - a switch statement In-Reply-To: <20070604002922.GB30461@zodiac.codesimply.com> References: <20070604002922.GB30461@zodiac.codesimply.com> Message-ID: <814422ce0706040436t4c9bf836g85d4f9d26c36f5f0@mail.gmail.com> > > > ...but how about some additional awesome magic? Who doesn't like magic? :) given ($variable) { > when (1) { # $variable == 1 > do_something_one; > } > > when (@edge_cases) { # if $variable in @edge_cases > do_edge_case_handler; > } > > when ($_ > 10e6) { # if $variable is over a million > do_huge_handler; > } > > when (\&test) { # if test($_) is true > say "the test was true!"; > continue; > } > > default { > default_handler; > } > } Regex? ___SNIP___ when ( /^\Q$somepattern\E$/) { say "seen $somepattern" } ___SNIP___ -- "You are never dedicated to something you have complete confidence in. No one is fanatically shouting that the sun is going to rise tomorrow. They know it's going to rise tomorrow. " -- Robert M Pirsig -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070604/5db5ab5b/attachment.html From rjbs-perl-abe at lists.manxome.org Mon Jun 4 05:23:41 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Mon, 4 Jun 2007 08:23:41 -0400 Subject: [ABE.pm] perl 5.10 rules! - a switch statement In-Reply-To: <814422ce0706040436t4c9bf836g85d4f9d26c36f5f0@mail.gmail.com> References: <20070604002922.GB30461@zodiac.codesimply.com> <814422ce0706040436t4c9bf836g85d4f9d26c36f5f0@mail.gmail.com> Message-ID: <20070604122341.GA4540@knight.manxome.org> * Ted Fiedler [2007-06-04T07:36:09] > Regex? > > ___SNIP___ > > when ( /^\Q$somepattern\E$/) > { > say "seen $somepattern" > } > > ___SNIP___ But of course! Heck, you don't even need to use qr{}! -- rjbs From fiedlert at gmail.com Mon Jun 4 05:40:52 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Mon, 4 Jun 2007 08:40:52 -0400 Subject: [ABE.pm] perl 5.10 rules! - a switch statement In-Reply-To: <20070604122341.GA4540@knight.manxome.org> References: <20070604002922.GB30461@zodiac.codesimply.com> <814422ce0706040436t4c9bf836g85d4f9d26c36f5f0@mail.gmail.com> <20070604122341.GA4540@knight.manxome.org> Message-ID: <814422ce0706040540s72156386i5de0e8dd50da4630@mail.gmail.com> > > > > > > ___SNIP___ > > > > when ( /^\Q$somepattern\E$/) > > { > > say "seen $somepattern" > > } > > > > ___SNIP___ > > But of course! Heck, you don't even need to use qr{}! > > Looks like its time to install 5.9.4! -- "You are never dedicated to something you have complete confidence in. No one is fanatically shouting that the sun is going to rise tomorrow. They know it's going to rise tomorrow. " -- Robert M Pirsig -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070604/4f206f3d/attachment.html From rjbs-perl-abe at lists.manxome.org Mon Jun 4 06:17:21 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Mon, 4 Jun 2007 09:17:21 -0400 Subject: [ABE.pm] perl 5.10 rules! - a switch statement In-Reply-To: <814422ce0706040540s72156386i5de0e8dd50da4630@mail.gmail.com> References: <20070604002922.GB30461@zodiac.codesimply.com> <814422ce0706040436t4c9bf836g85d4f9d26c36f5f0@mail.gmail.com> <20070604122341.GA4540@knight.manxome.org> <814422ce0706040540s72156386i5de0e8dd50da4630@mail.gmail.com> Message-ID: <20070604131721.GA4745@knight.manxome.org> * Ted Fiedler [2007-06-04T08:40:52] > Looks like its time to install 5.9.4! I suggest you actually rsync from current to get the "blead" perl marked 5.9.5. at 5.9.4, ~~ requires you to use feature, which is not needed in the latest builds. -- rjbs From mct at toren.net Mon Jun 4 15:32:53 2007 From: mct at toren.net (Michael C. Toren) Date: Mon, 4 Jun 2007 18:32:53 -0400 Subject: [ABE.pm] perl 5.10 rules! - a switch statement In-Reply-To: <20070604002922.GB30461@zodiac.codesimply.com> References: <20070604002922.GB30461@zodiac.codesimply.com> Message-ID: <20070604223253.GB24073@netisland.net> I have to say that I'm fairly unimpressed with "given/when", but *this*: > In 5.10, you could have solved this problem at the outside by writing: > > die "We don't support your browser!" if $user_agent ~~ $unsupported_browser; > > When you started out, you'd have put a string in there, and it would use eq. > Later, you'd put in an arrayref, and it would check whether $user_agent was > in the arrayref. Finally, you'd put in a coderef and it would call it. By > saying that something is a "smart match" target, rather than something more > specific, you can make your code very flexible without writing a lot of > polymorphism on your own. ...is really cool! I can't wait to play with it. :-) Thanks, -mct From fiedlert at gmail.com Tue Jun 5 05:31:45 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Tue, 5 Jun 2007 08:31:45 -0400 Subject: [ABE.pm] Alternate Perl Installs and/or how to deal with indolence Message-ID: <814422ce0706050531w2a5b233i95232cf7c9da2ffa@mail.gmail.com> Just curious how others either deal or don't deal w/ this situation. At $job we run Suse 9.3 on a server - I can't just upgrade the OS w/o an act of God. Perl is version 5.8.3 Id like to be at current, and later 5.10 when it arrives. I rely heavily on Perl for most of what I do on this system. And Perl 5.8.3 is just old. Now when running Releases such as or RedHat or whatever where Perl is installed via a packaging system, as most probably realize ( and lucky if you don't ) you cant just remove the Perl package because there are 1.2Giga-cruft packages that have Perl as a dependency. You would end up removing some unjustifiable portions of your system. What I have done in the past has been to install Perl into say /opt or /usr/local. I guess this is acceptable, BUT now after I test each program with #!/opt/Perl/bin/perl I need to maintain this alternate structure and make sure everyone else does as well. Im lazy. Is this the norm? A norm? ( Not the laziness, but the alternate Perl install... ) Also - when I run /opt/Perl/bin/perl -MCPAN -eshell will modules be installed in the correct locations? Easy enough to test myself, but laziness pervades and I must ask before trying :) Ted -- "You are never dedicated to something you have complete confidence in. No one is fanatically shouting that the sun is going to rise tomorrow. They know it's going to rise tomorrow. " -- Robert M Pirsig -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070605/178f71ab/attachment.html From rjbs-perl-abe at lists.manxome.org Tue Jun 5 06:13:19 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Tue, 5 Jun 2007 09:13:19 -0400 Subject: [ABE.pm] Alternate Perl Installs and/or how to deal with indolence In-Reply-To: <814422ce0706050531w2a5b233i95232cf7c9da2ffa@mail.gmail.com> References: <814422ce0706050531w2a5b233i95232cf7c9da2ffa@mail.gmail.com> Message-ID: <20070605131319.GA9867@zodiac.codesimply.com> * Ted Fiedler [2007-06-05T08:31:45] > What I have done in the past has been to install Perl into say /opt or > /usr/local. I guess this is acceptable, BUT now after I test each program > with I think your best options are: (a) build a package for your OS's packaging system (perl-5.10-proprietary.rpm) or (b) install to /opt/perl-5.8.9 > Is this the norm? A norm? ( Not the laziness, but the alternate Perl > install... ) I don't know, honestly. > Also - when I run /opt/Perl/bin/perl -MCPAN -eshell will modules be > installed in the correct locations? Easy enough to test myself, but laziness > pervades and I must ask before trying :) Yes. -- rjbs From rjbs-perl-abe at lists.manxome.org Tue Jun 5 07:32:03 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Tue, 5 Jun 2007 10:32:03 -0400 Subject: [ABE.pm] perl 5.10 rules! - assertions In-Reply-To: <20070601004606.GA22807@knight.manxome.org> References: <20070530122502.GA12438@knight> <20070601004606.GA22807@knight.manxome.org> Message-ID: <20070605143203.GB6401@knight.office.icgroup.com> * Ricardo SIGNES [2007-05-31T20:46:07] > * Ricardo SIGNES [2007-05-30T08:25:02] > > I'll be honest: there are a bunch of things I don't love about the new > > assertions interface. > > Some of my complaints aired: > > http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2007-06/msg00009.html As a result of some discussion relating to this thread and on IRC, assertions have been removed from 5.9.5. This is good! It means that if they're put back in for 5.12, they will be well though-out and designed, instead of sort of sketch and weird. -- rjbs From faber at linuxnj.com Tue Jun 5 09:11:23 2007 From: faber at linuxnj.com (Faber J. Fedor) Date: Tue, 5 Jun 2007 12:11:23 -0400 Subject: [ABE.pm] self-modifying data structures Message-ID: <20070605161123.GA3225@neptune.faber.nom> I need to transfer data between two sets of six tables in a MySQL database. I need to repeat this operation across four servers. So I wrote a little Perl script to do the former and I'm going to copy and run it on all four servers. The snag is, the data to be copied exists only on the first server. What I thought would be fun to do is to write a script that does this: populate the first set of tables if the data doesn't exist copy the data to the second set of tables This implies that the program has a copy of the data. Now, I could hard-code the data to be copied but that's too much work. What I want to do is: if command-line flag is set, read data from tables and update my source code with the new data IOW, I want my program to modify its source code/file by updating a data structure within the program/file. I think the __DATA__ tag is going to be useful here but I'm not sure. Any suggestions on how to do this? -- Regards, Faber Fedor President Linux New Jersey, Inc. 908-320-0357 800-706-0701 http://www.linuxnj.com From rjbs-perl-abe at lists.manxome.org Tue Jun 5 10:00:05 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Tue, 5 Jun 2007 13:00:05 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <20070605161123.GA3225@neptune.faber.nom> References: <20070605161123.GA3225@neptune.faber.nom> Message-ID: <20070605170005.GA6503@knight.office.icgroup.com> * "Faber J. Fedor" [2007-06-05T12:11:23] > IOW, I want my program to modify its source code/file by updating a data > structure within the program/file. I think the __DATA__ tag is going to be > useful here but I'm not sure. > > Any suggestions on how to do this? Yes: don't. Instead, put the data in another file. Using __DATA__ for anything other than quick one-offs like mailing Christmas emails to your aunties is a recipe for disaster. Updating __DATA__ is a recipe for global devastation the likes of which the world has never seen before. -- rjbs From rjbs-perl-abe at lists.manxome.org Tue Jun 5 10:00:05 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Tue, 5 Jun 2007 13:00:05 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <20070605161123.GA3225@neptune.faber.nom> References: <20070605161123.GA3225@neptune.faber.nom> Message-ID: <20070605170005.GA6503@knight.office.icgroup.com> * "Faber J. Fedor" [2007-06-05T12:11:23] > IOW, I want my program to modify its source code/file by updating a data > structure within the program/file. I think the __DATA__ tag is going to be > useful here but I'm not sure. > > Any suggestions on how to do this? Yes: don't. Instead, put the data in another file. Using __DATA__ for anything other than quick one-offs like mailing Christmas emails to your aunties is a recipe for disaster. Updating __DATA__ is a recipe for global devastation the likes of which the world has never seen before. -- rjbs From john-abe at apt202.net Tue Jun 5 15:24:54 2007 From: john-abe at apt202.net (John Cappiello) Date: Tue, 5 Jun 2007 18:24:54 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <20070605170005.GA6503@knight.office.icgroup.com> References: <20070605161123.GA3225@neptune.faber.nom> <20070605170005.GA6503@knight.office.icgroup.com> Message-ID: <20070605222452.GB23891@apt202.net> On Tue, Jun 05, 2007 at 01:00:05PM -0400, Ricardo SIGNES wrote: > Updating __DATA__ is a recipe for global devastation the likes of > which the world has never seen before. Global Thermo Nuclear War -- jcap From rjbs-perl-abe at lists.manxome.org Tue Jun 5 16:41:14 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Tue, 5 Jun 2007 19:41:14 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <20070605222452.GB23891@apt202.net> References: <20070605161123.GA3225@neptune.faber.nom> <20070605170005.GA6503@knight.office.icgroup.com> <20070605222452.GB23891@apt202.net> Message-ID: <20070605234114.GA7031@knight.manxome.org> * John Cappiello [2007-06-05T18:24:54] > On Tue, Jun 05, 2007 at 01:00:05PM -0400, Ricardo SIGNES wrote: > > Updating __DATA__ is a recipe for global devastation the likes of > > which the world has never seen before. > > Global Thermo Nuclear War ...nearly happened because of a computer programmer with a son named Joshua. -- rjbs From faber at linuxnj.com Tue Jun 5 17:49:26 2007 From: faber at linuxnj.com (Faber Fedor) Date: Tue, 5 Jun 2007 20:49:26 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <20070605170005.GA6503@knight.office.icgroup.com> References: <20070605161123.GA3225@neptune.faber.nom> <20070605170005.GA6503@knight.office.icgroup.com> Message-ID: <300ccfa50706051749g4780c6b9xd2419aa251fc0d2@mail.gmail.com> On 6/5/07, Ricardo SIGNES wrote: > > * "Faber J. Fedor" [2007-06-05T12:11:23] > > IOW, I want my program to modify its source code/file by updating a data > > structure within the program/file. I think the __DATA__ tag is going to > be > > useful here but I'm not sure. > > > > Any suggestions on how to do this? > > Yes: don't. > > Instead, put the data in another file. Well that's no fun! Updating __DATA__ is a recipe > for global devastation the likes of which the world has never seen before. Fist you say "Don't do it" and then you give me a reason to do it. Make up your mind! One of these days I'm going to figure out how to write self-modifying code. -- Faber -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070605/d363b702/attachment.html From fiedlert at gmail.com Tue Jun 5 18:17:44 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Tue, 5 Jun 2007 21:17:44 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <300ccfa50706051747u5cc2864dt635d1d6855fa30fd@mail.gmail.com> References: <20070605161123.GA3225@neptune.faber.nom> <814422ce0706051025s26df9529p8aca29801e55fa43@mail.gmail.com> <300ccfa50706051747u5cc2864dt635d1d6855fa30fd@mail.gmail.com> Message-ID: <814422ce0706051817g3f7e5d3fp1cfc946cd684caa8@mail.gmail.com> > > On 6/5/07, Ted Fiedler wrote: > > > > > I would just prepare and execute a statement... Then use a sub like this > > ( which returns a hash ) then compare the hashes. > > > > > I'm going to have to digest this and get back to you. > Ive been chewing on it for a year. Another thing I sometimes do depending on the size of the hash is to do md5 summing of the structure. get an md5 of the whole hash if thats different, get an md5 of each row ( by key ) if its the same move on, if the row md5 is different then I will actually compare the data. doing the check sums of the whole row is faster than comparing each value - mileage varies. so Ill have something that looks like this %table1 = ( key1 => ( md5sum => 123456, data => [ x,x,y,c ] ), key2 => ( md5sum => 124567, data => [5,6,,d,NULL,2], ); next if ( $table1{key1}{md5sum} = $table2{key1}{md5sum} ); Then compare the data in the arrays... Ive seen some things that Ric has posted regarding Perl 5.10 that may make my life easier ie switch statement and given that Im pretty eager to try. Ted -- > > Faber > > > -- The optimist thinks that this is the best of all possible worlds, and the pessimist knows it. -- J. Robert Oppenheimer, "Bulletin of Atomic Scientists" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070605/4e4b1673/attachment.html From fiedlert at gmail.com Tue Jun 5 18:28:04 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Tue, 5 Jun 2007 21:28:04 -0400 Subject: [ABE.pm] perldoc question Message-ID: <814422ce0706051828g2000ac47t7b3e97631e6a8c09@mail.gmail.com> so I have 5.9.4 installed under /opt/perlbleed how do I make perldoc search that documentation instead of the system default locations? Ted -- The optimist thinks that this is the best of all possible worlds, and the pessimist knows it. -- J. Robert Oppenheimer, "Bulletin of Atomic Scientists" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070605/9c53742b/attachment.html From faber at linuxnj.com Tue Jun 5 18:42:31 2007 From: faber at linuxnj.com (Faber Fedor) Date: Tue, 5 Jun 2007 21:42:31 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <814422ce0706051817g3f7e5d3fp1cfc946cd684caa8@mail.gmail.com> References: <20070605161123.GA3225@neptune.faber.nom> <814422ce0706051025s26df9529p8aca29801e55fa43@mail.gmail.com> <300ccfa50706051747u5cc2864dt635d1d6855fa30fd@mail.gmail.com> <814422ce0706051817g3f7e5d3fp1cfc946cd684caa8@mail.gmail.com> Message-ID: <300ccfa50706051842m9c84bfavaff2161b3a992952@mail.gmail.com> On 6/5/07, Ted Fiedler wrote: > > Ive been chewing on it for a year. Another thing I sometimes do depending > on the size of the hash is to do md5 summing of the structure. > > get an md5 of the whole hash if thats different, get an md5 of each row ( > by key ) if its the same move on, if the row md5 is different then I will > actually compare the data. doing the check sums of the whole row is faster > than comparing each value - mileage varies. > That's a really freakin' cool idea! I'm going to have to look for an application of that idea! > Ive seen some things that Ric has posted regarding Perl 5.10 that may make > my life easier ie switch statement and given that Im pretty eager to try. > I didn't know about the "hash as a dispatch table" trick. I'm looking forward to using that one. You know, I think we need to do some more technical stuff in this group. The monthly dinners are good and all that, but anyone who's Internet-savvy could fit in. We need to do some more hard-core Perl stuff. Why did we stop having meetings at the university? -- faber -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070605/5fa9fa7d/attachment.html From fiedlert at gmail.com Tue Jun 5 18:45:27 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Tue, 5 Jun 2007 21:45:27 -0400 Subject: [ABE.pm] perldoc question Message-ID: <814422ce0706051845s90fd617o731f00b057d0c609@mail.gmail.com> AHA! find /opt/perlbleed/man/man1 -name "*.1" > /opt/perlbleed/lib/5.9.4/pod.idx find /opt/perlbleed/man/man3 -name "*.3" >> /opt/perlbleed/lib/5.9.4/pod.idx find /opt/perlbleed -name "*.pod" >> /opt/perlbleed/lib/5.9.4/pod.idx /opt/perlbleed/bin/perldoc -X perlsyn Ted -- The optimist thinks that this is the best of all possible worlds, and the pessimist knows it. -- J. Robert Oppenheimer, "Bulletin of Atomic Scientists" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070605/ff405a0c/attachment.html From faber at linuxnj.com Tue Jun 5 18:48:04 2007 From: faber at linuxnj.com (Faber Fedor) Date: Tue, 5 Jun 2007 21:48:04 -0400 Subject: [ABE.pm] WTF is this code doing? Message-ID: <300ccfa50706051848l346d9811sa7de5aefe4f596be@mail.gmail.com> Since I'm on a self-modifying code kick, I googled the phrase and stumbled across this: #!/util/bin/perl $s = q@($t = $s) =~ s/\045/\100/g; print "#!/util/bin/perl\n\$s = q%$s%;$t"; @;($t = $s) =~ s/\045/\100/g; print "#!/util/bin/perl\n\$s = q@$s@;$t"; What does q@($t = $s) and @;($t = $s) =~ mean? -- Faber -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070605/be364bb8/attachment-0001.html From rjbs-perl-abe at lists.manxome.org Tue Jun 5 19:15:35 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Tue, 5 Jun 2007 22:15:35 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <300ccfa50706051842m9c84bfavaff2161b3a992952@mail.gmail.com> References: <20070605161123.GA3225@neptune.faber.nom> <814422ce0706051025s26df9529p8aca29801e55fa43@mail.gmail.com> <300ccfa50706051747u5cc2864dt635d1d6855fa30fd@mail.gmail.com> <814422ce0706051817g3f7e5d3fp1cfc946cd684caa8@mail.gmail.com> <300ccfa50706051842m9c84bfavaff2161b3a992952@mail.gmail.com> Message-ID: <20070606021535.GA7477@knight.manxome.org> * Faber Fedor [2007-06-05T21:42:31] > You know, I think we need to do some more technical stuff in this group. The > monthly dinners are good and all that, but anyone who's Internet-savvy could > fit in. We need to do some more hard-core Perl stuff. > > Why did we stop having meetings at the university? I don't remember if there are specifics. Perhaps we should decide on topics, line up dates, and then figure out a venue. -- rjbs From rjbs-perl-abe at lists.manxome.org Tue Jun 5 19:16:30 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Tue, 5 Jun 2007 22:16:30 -0400 Subject: [ABE.pm] perldoc question In-Reply-To: <814422ce0706051845s90fd617o731f00b057d0c609@mail.gmail.com> References: <814422ce0706051845s90fd617o731f00b057d0c609@mail.gmail.com> Message-ID: <20070606021630.GB7477@knight.manxome.org> * Ted Fiedler [2007-06-05T21:45:27] > find /opt/perlbleed/man/man1 -name "*.1" > /opt/perlbleed/lib/5.9.4/pod.idx > find /opt/perlbleed/man/man3 -name "*.3" >> > /opt/perlbleed/lib/5.9.4/pod.idx > find /opt/perlbleed -name "*.pod" >> /opt/perlbleed/lib/5.9.4/pod.idx Installing a dev version of perl normally will not clobber perl or perldoc, but will give you perl5.9.4 and perldoc5.9.4, too. -- rjbs From rjbs-perl-abe at lists.manxome.org Tue Jun 5 19:25:06 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Tue, 5 Jun 2007 22:25:06 -0400 Subject: [ABE.pm] WTF is this code doing? In-Reply-To: <300ccfa50706051848l346d9811sa7de5aefe4f596be@mail.gmail.com> References: <300ccfa50706051848l346d9811sa7de5aefe4f596be@mail.gmail.com> Message-ID: <20070606022506.GC7477@knight.manxome.org> * Faber Fedor [2007-06-05T21:48:04] > Since I'm on a self-modifying code kick, I googled the phrase and stumbled > across this: > > #!/util/bin/perl > $s = q@($t = $s) =~ s/\045/\100/g; > print "#!/util/bin/perl\n\$s = q%$s%;$t"; > @;($t = $s) =~ s/\045/\100/g; > print "#!/util/bin/perl\n\$s = q@$s@;$t"; In perldoc perlop, there's a section on "Quote-like operators." It basically says something like this: Did you know that when you write: if ($string =~ /abcdef/) { ... } It's the same as: if ($string =~ m/abcdef/) { ... } ? Well, it is. The m is optional if you use // -- and I say "if you use //" because you can use other delimiters: if ($string =~ m|abcdef|) { ... } # some other repeated character if ($string =~ m$abcdef$) { ... } # another repeated character if ($string =~ m{abcdef}) { ... } # an open/close pair of characters This is really convenient when you want to have a / in there, because you can use something other than a /, and then you don't have to \ all your /. Not having to \ all my / makes me feel like this: \o/ | / \ Some pairs are magic, and have special meaning, like m?foo? -- but you can look into that on your own. Anyway, m// isn't the only thing that works this way. Just like // is secretly m// in the context above, often "" is secretly qq"" and '' is secretly q''. m - matching patern qq - quoted string (interpolates scalars and arrays) q - quoted string (no interpolation) So! > $s = q@($t = $s) =~ s/\045/\100/g; > print "#!/util/bin/perl\n\$s = q%$s%;$t"; > @;($t = $s) =~ s/\045/\100/g; > print "#!/util/bin/perl\n\$s = q@$s@;$t"; The first @ begins a non-interpolated string, which ends at the next @. That program says: $s = '($t = $s) =~ s/\045/\100/g;' . "\n" . 'print "#!/util/bin/perl\n\$s = ... and so on. Does that help? -- rjbs From fiedlert at gmail.com Wed Jun 6 04:28:11 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Wed, 6 Jun 2007 07:28:11 -0400 Subject: [ABE.pm] perldoc question In-Reply-To: <20070606021630.GB7477@knight.manxome.org> References: <814422ce0706051845s90fd617o731f00b057d0c609@mail.gmail.com> <20070606021630.GB7477@knight.manxome.org> Message-ID: <814422ce0706060428v4cdfffe3g524fd93a1660c29f@mail.gmail.com> > > > Installing a dev version of perl normally will not clobber perl or > perldoc, but > will give you perl5.9.4 and perldoc5.9.4, too. > > Another AHA. I just wasnt finding what I was looking for w/ perldoc5.9.4 so I ASSuMEd that it was because it did not know where to look, hence a pod.idx Ted -- The optimist thinks that this is the best of all possible worlds, and the pessimist knows it. -- J. Robert Oppenheimer, "Bulletin of Atomic Scientists" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070606/483683c0/attachment.html From fiedlert at gmail.com Wed Jun 6 05:07:21 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Wed, 6 Jun 2007 08:07:21 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <300ccfa50706051842m9c84bfavaff2161b3a992952@mail.gmail.com> References: <20070605161123.GA3225@neptune.faber.nom> <814422ce0706051025s26df9529p8aca29801e55fa43@mail.gmail.com> <300ccfa50706051747u5cc2864dt635d1d6855fa30fd@mail.gmail.com> <814422ce0706051817g3f7e5d3fp1cfc946cd684caa8@mail.gmail.com> <300ccfa50706051842m9c84bfavaff2161b3a992952@mail.gmail.com> Message-ID: <814422ce0706060507t4763f1a8i6ea5f8d4b7f4095d@mail.gmail.com> On 6/5/07, Faber Fedor wrote: > > On 6/5/07, Ted Fiedler wrote: > > > > Ive been chewing on it for a year. Another thing I sometimes do > > depending on the size of the hash is to do md5 summing of the structure. > > > > get an md5 of the whole hash if thats different, get an md5 of each row > > ( by key ) if its the same move on, if the row md5 is different then I will > > actually compare the data. doing the check sums of the whole row is faster > > than comparing each value - mileage varies. > > > > That's a really freakin' cool idea! > > I'm going to have to look for an application of that idea! > Yes - some of the speed benefits alone have made my day :) you should also take a look at Tie::DBI - there are some performance considerations with that extra convenience though. This is all well documented in the pod. Ive seen some things that Ric has posted regarding Perl 5.10 that may make > > my life easier ie switch statement and given that Im pretty eager to try. > > > > I didn't know about the "hash as a dispatch table" trick. I'm looking > forward to using that one. > > You know, I think we need to do some more technical stuff in this group. > The monthly dinners are good and all that, but anyone who's Internet-savvy > could fit in. We need to do some more hard-core Perl stuff. > Id like to see/do some more tech stuff as well what about an abe.pmconference? I went to a security conference given by the Harrisburg LUG a few years back and it was pretty good. Something like that on a smaller scale would be cool to organize. Ted -- The optimist thinks that this is the best of all possible worlds, and the pessimist knows it. -- J. Robert Oppenheimer, "Bulletin of Atomic Scientists" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070606/40ccffa9/attachment.html From rjbs-perl-abe at lists.manxome.org Wed Jun 6 05:29:23 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Wed, 6 Jun 2007 08:29:23 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <814422ce0706060507t4763f1a8i6ea5f8d4b7f4095d@mail.gmail.com> References: <20070605161123.GA3225@neptune.faber.nom> <814422ce0706051025s26df9529p8aca29801e55fa43@mail.gmail.com> <300ccfa50706051747u5cc2864dt635d1d6855fa30fd@mail.gmail.com> <814422ce0706051817g3f7e5d3fp1cfc946cd684caa8@mail.gmail.com> <300ccfa50706051842m9c84bfavaff2161b3a992952@mail.gmail.com> <814422ce0706060507t4763f1a8i6ea5f8d4b7f4095d@mail.gmail.com> Message-ID: <20070606122923.GA8045@knight.manxome.org> * Ted Fiedler [2007-06-06T08:07:21] > Id like to see/do some more tech stuff as well what about an > abe.pmconference? I went to a security conference given by the Harrisburg > LUG a few years back and it was pretty good. Something like that on a smaller > scale would be cool to organize. What would you expect such an event to be like? -- rjbs From fiedlert at gmail.com Wed Jun 6 06:22:47 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Wed, 6 Jun 2007 09:22:47 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <20070606122923.GA8045@knight.manxome.org> References: <20070605161123.GA3225@neptune.faber.nom> <814422ce0706051025s26df9529p8aca29801e55fa43@mail.gmail.com> <300ccfa50706051747u5cc2864dt635d1d6855fa30fd@mail.gmail.com> <814422ce0706051817g3f7e5d3fp1cfc946cd684caa8@mail.gmail.com> <300ccfa50706051842m9c84bfavaff2161b3a992952@mail.gmail.com> <814422ce0706060507t4763f1a8i6ea5f8d4b7f4095d@mail.gmail.com> <20070606122923.GA8045@knight.manxome.org> Message-ID: <814422ce0706060622xdb1b769me483144e8eabb1e5@mail.gmail.com> > What would you expect such an event to be like? well from the smaller ones that Ive been to, they usually are at a university w/ some corporate / small business sponsorship. And usually involve food: read as free pizza :) I'd always be interested in DBI talks, email talks, cool new 5.10 feature talks :), and of course the (most) informational hallway talks. Id even be willing to help organize if need be. Ted -- The optimist thinks that this is the best of all possible worlds, and the pessimist knows it. -- J. Robert Oppenheimer, "Bulletin of Atomic Scientists" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070606/c9f52618/attachment.html From rjbs-perl-abe at lists.manxome.org Wed Jun 6 07:05:52 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Wed, 6 Jun 2007 10:05:52 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <814422ce0706060622xdb1b769me483144e8eabb1e5@mail.gmail.com> References: <20070605161123.GA3225@neptune.faber.nom> <814422ce0706051025s26df9529p8aca29801e55fa43@mail.gmail.com> <300ccfa50706051747u5cc2864dt635d1d6855fa30fd@mail.gmail.com> <814422ce0706051817g3f7e5d3fp1cfc946cd684caa8@mail.gmail.com> <300ccfa50706051842m9c84bfavaff2161b3a992952@mail.gmail.com> <814422ce0706060507t4763f1a8i6ea5f8d4b7f4095d@mail.gmail.com> <20070606122923.GA8045@knight.manxome.org> <814422ce0706060622xdb1b769me483144e8eabb1e5@mail.gmail.com> Message-ID: <20070606140552.GA9316@knight.manxome.org> * Ted Fiedler [2007-06-06T09:22:47] > well from the smaller ones that Ive been to, they usually are at a > university w/ some corporate / small business sponsorship. And usually > involve food: read as free pizza :) > > I'd always be interested in DBI talks, email talks, cool new 5.10 feature > talks :), and of course the (most) informational hallway talks. jcap had talked about getting a Philly Perl Workshop going, but I've heard pretty much nothing on PHL.pm. I think nobody wanted to spearhead things. Doing one here would be cheaper, and maybe we're more motivated. The downside is that we might get fewer people... but I don't realy care. Would we want more than one track? Maybe we should look at what was done in Pittsburgh as a first look. -- rjbs From faber at linuxnj.com Wed Jun 6 07:13:15 2007 From: faber at linuxnj.com (Faber Fedor) Date: Wed, 6 Jun 2007 10:13:15 -0400 Subject: [ABE.pm] WTF is this code doing? In-Reply-To: <20070606022506.GC7477@knight.manxome.org> References: <300ccfa50706051848l346d9811sa7de5aefe4f596be@mail.gmail.com> <20070606022506.GC7477@knight.manxome.org> Message-ID: <300ccfa50706060713p302dc9a2yc442e92f093ed014@mail.gmail.com> On 6/5/07, Ricardo SIGNES wrote: > > Did you know that when you write: > > if ($string =~ /abcdef/) { ... } > > It's the same as: > > if ($string =~ m/abcdef/) { ... } > > ? Yeah. Well, it is. The m is optional if you use // -- and I say "if you use //" > because you can use other delimiters: > > if ($string =~ m|abcdef|) { ... } # some other repeated character > if ($string =~ m$abcdef$) { ... } # another repeated character > if ($string =~ m{abcdef}) { ... } # an open/close pair of characters Unix 102: Avoiding the leaning toothpick syndrome. Some pairs are magic, and have special meaning, like m?foo? -- but you can > look > into that on your own. > > Anyway, m// isn't the only thing that works this way. Just like // is > secretly > m// in the context above, often "" is secretly qq"" and '' is secretly > q''. > > m - matching patern > qq - quoted string (interpolates scalars and arrays) > q - quoted string (no interpolation) > > So! > > > $s = q@($t = $s) =~ s/\045/\100/g; > > print "#!/util/bin/perl\n\$s = q%$s%;$t"; > > @;($t = $s) =~ s/\045/\100/g; > > print "#!/util/bin/perl\n\$s = q@$s@;$t"; > > The first @ begins a non-interpolated string, which ends at the next > @. That > program says: > $s = '($t = $s) =~ s/\045/\100/g;' > . "\n" > . 'print "#!/util/bin/perl\n\$s = ... > > and so on. Does that help? So I could use q'', q@@, q||. q!! etc instead of q() just like I can use s''', s@@@, s||| and s!!! instead of s/// ? -- Faber -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070606/73926bd9/attachment.html From faber at linuxnj.com Wed Jun 6 07:16:42 2007 From: faber at linuxnj.com (Faber Fedor) Date: Wed, 6 Jun 2007 10:16:42 -0400 Subject: [ABE.pm] YAPC.ABE [WAS: Re: self-modifying data structures ] Message-ID: <300ccfa50706060716h43c58746kfe00c42ed4f8784b@mail.gmail.com> On 6/6/07, Ricardo SIGNES wrote: > > * Ted Fiedler [2007-06-06T09:22:47] > > well from the smaller ones that Ive been to, they usually are at a > > university w/ some corporate / small business sponsorship. And usually > > involve food: read as free pizza :) > > > > I'd always be interested in DBI talks, email talks, cool new 5.10feature > > talks :), and of course the (most) informational hallway talks. > > jcap had talked about getting a Philly Perl Workshop going, but I've heard > pretty much nothing on PHL.pm. I think nobody wanted to spearhead things. > > Doing one here would be cheaper, and maybe we're more motivated. The > downside > is that we might get fewer people... but I don't realy care. Why don't we figure out what we have in resources, how much it'll cost and how we can break even? Would we want more than one track? Maybe we should look at what was done in > Pittsburgh as a first look. What about Houston? We can pick their brains in three weeks time! My concern is getting enough speakers/topics. Can we cover that first? -- Faber -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070606/f6f09910/attachment.html From fiedlert at gmail.com Wed Jun 6 07:17:04 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Wed, 6 Jun 2007 10:17:04 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <20070606140552.GA9316@knight.manxome.org> References: <20070605161123.GA3225@neptune.faber.nom> <814422ce0706051025s26df9529p8aca29801e55fa43@mail.gmail.com> <300ccfa50706051747u5cc2864dt635d1d6855fa30fd@mail.gmail.com> <814422ce0706051817g3f7e5d3fp1cfc946cd684caa8@mail.gmail.com> <300ccfa50706051842m9c84bfavaff2161b3a992952@mail.gmail.com> <814422ce0706060507t4763f1a8i6ea5f8d4b7f4095d@mail.gmail.com> <20070606122923.GA8045@knight.manxome.org> <814422ce0706060622xdb1b769me483144e8eabb1e5@mail.gmail.com> <20070606140552.GA9316@knight.manxome.org> Message-ID: <814422ce0706060717g78290aecs4134b689bf92ace4@mail.gmail.com> > jcap had talked about getting a Philly Perl Workshop going, but I've heard > pretty much nothing on PHL.pm. I think nobody wanted to spearhead things. maybe a combined effort of a few motivated individuals would be more successful. ABE is not that far from philly... Doing one here would be cheaper, and maybe we're more motivated. The > downside > is that we might get fewer people... but I don't realy care. Cheaper may be a motivation. Pizza too :) Would we want more than one track? Maybe we should look at what was done in > Pittsburgh as a first look. They Documented some of what they learned: http://docs.google.com/View?docid=dgd8fc6n_0nh3975 -- > rjbs > _______________________________________________ > ABE-pm mailing list > ABE-pm at pm.org > http://mail.pm.org/mailman/listinfo/abe-pm > -- The optimist thinks that this is the best of all possible worlds, and the pessimist knows it. -- J. Robert Oppenheimer, "Bulletin of Atomic Scientists" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070606/1a2d4b20/attachment.html From tfreedman at iqep.com Wed Jun 6 07:31:47 2007 From: tfreedman at iqep.com (Tom Freedman) Date: Wed, 6 Jun 2007 10:31:47 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <20070605234114.GA7031@knight.manxome.org> References: <20070605161123.GA3225@neptune.faber.nom> <20070605170005.GA6503@knight.office.icgroup.com> <20070605222452.GB23891@apt202.net> <20070605234114.GA7031@knight.manxome.org> Message-ID: > -----Original Message----- > From: Ricardo SIGNES > Subject: Re: [ABE.pm] self-modifying data structures > > * John Cappiello [2007-06-05T18:24:54] > > On Tue, Jun 05, 2007 at 01:00:05PM -0400, Ricardo SIGNES wrote: > > > Updating __DATA__ is a recipe for global devastation the likes of > > > which the world has never seen before. > > > > Global Thermo Nuclear War > > ...nearly happened because of a computer programmer with a son named > Joshua. Hey now! Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message. From john-abe at apt202.net Wed Jun 6 07:45:40 2007 From: john-abe at apt202.net (John Cappiello) Date: Wed, 6 Jun 2007 10:45:40 -0400 Subject: [ABE.pm] YAPC.ABE [WAS: Re: self-modifying data structures ] In-Reply-To: <300ccfa50706060716h43c58746kfe00c42ed4f8784b@mail.gmail.com> References: <300ccfa50706060716h43c58746kfe00c42ed4f8784b@mail.gmail.com> Message-ID: <20070606144539.GC23891@apt202.net> On Wed, Jun 06, 2007 at 10:16:42AM -0400, Faber Fedor wrote: > Would we want more than one track? Maybe we should look at what was done in > Pittsburgh as a first look. Actually, since the PPW, I've been thinking and talking about doing the same in Phili. We actually had a meeting about it, and I think the ball was somewhere in my court, but I don't really remember what my task was :\ This is going back to last October mind you. A 1 / 2 day event in PHL (or ABE) could be a great event imo. The first thing though before deciding on how many tracks, etc, is just a function of what we want to accomplish, that will attract enough people to make it worth it. This area is surrounded by a number of cities close enough to drive, so it's a great location imo. We just need the right topics, etc. Also, given that PPW seems to be happening again this year, we face a little risk of burnout with this area. However, given the date as it is now, and how most of these fall spring summer, fall, it might be advantageous to think about something for next January. -- jcap From john-abe at apt202.net Wed Jun 6 07:47:36 2007 From: john-abe at apt202.net (John Cappiello) Date: Wed, 6 Jun 2007 10:47:36 -0400 Subject: [ABE.pm] self-modifying data structures In-Reply-To: <20070606140552.GA9316@knight.manxome.org> References: <20070605161123.GA3225@neptune.faber.nom> <814422ce0706051025s26df9529p8aca29801e55fa43@mail.gmail.com> <300ccfa50706051747u5cc2864dt635d1d6855fa30fd@mail.gmail.com> <814422ce0706051817g3f7e5d3fp1cfc946cd684caa8@mail.gmail.com> <300ccfa50706051842m9c84bfavaff2161b3a992952@mail.gmail.com> <814422ce0706060507t4763f1a8i6ea5f8d4b7f4095d@mail.gmail.com> <20070606122923.GA8045@knight.manxome.org> <814422ce0706060622xdb1b769me483144e8eabb1e5@mail.gmail.com> <20070606140552.GA9316@knight.manxome.org> Message-ID: <20070606144735.GD23891@apt202.net> On Wed, Jun 06, 2007 at 10:05:52AM -0400, Ricardo SIGNES wrote: > jcap had talked about getting a Philly Perl Workshop going, but I've heard > pretty much nothing on PHL.pm. I think nobody wanted to spearhead things. Woops, didn't see this post before my other reply. I had no problem spear heading things, but I kinda felt like we left very wishy washy and that I no one really gave me ideas for a next step. I suppose I should have just made my own next steps. If I felt like I had some people interested in working with me, I think I would be more motivated. I dunno. I'd be up for the effort. -- jcap From rjbs-perl-abe at lists.manxome.org Wed Jun 6 07:51:47 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Wed, 6 Jun 2007 10:51:47 -0400 Subject: [ABE.pm] YAPC.ABE [WAS: Re: self-modifying data structures ] In-Reply-To: <300ccfa50706060716h43c58746kfe00c42ed4f8784b@mail.gmail.com> References: <300ccfa50706060716h43c58746kfe00c42ed4f8784b@mail.gmail.com> Message-ID: <20070606145147.GB9670@knight.manxome.org> * Faber Fedor [2007-06-06T10:16:42] > What about Houston? We can pick their brains in three weeks time! A YAPC is a much, much larger deal than a workshop. They last for days, have three tracks of talks at once, have to set up accomodations for everyone, etc. We just want, maybe, a day of talks, maybe two tracks, and then a big lounge to hack in. -- rjbs From rjbs-perl-abe at lists.manxome.org Wed Jun 6 07:50:32 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Wed, 6 Jun 2007 10:50:32 -0400 Subject: [ABE.pm] WTF is this code doing? In-Reply-To: <300ccfa50706060713p302dc9a2yc442e92f093ed014@mail.gmail.com> References: <300ccfa50706051848l346d9811sa7de5aefe4f596be@mail.gmail.com> <20070606022506.GC7477@knight.manxome.org> <300ccfa50706060713p302dc9a2yc442e92f093ed014@mail.gmail.com> Message-ID: <20070606145032.GA9670@knight.manxome.org> * Faber Fedor [2007-06-06T10:13:15] > So I could use q'', q@@, q||. q!! etc instead of q() just like I can use > s''', s@@@, s||| and s!!! instead of s/// ? Quite right. Also, since you bring up s///, it's an oft-overlooked feature that if you use a set of open/close characters, you end up with two pairs (rather than three dividers) which can then have whitespace between them: s/foo/bar/; # three dividers s{foo}{bar}; # two pairs s{foo} # same... {bar}; # ...thing This is useful for larger chunks. -- rjbs From john-abe at apt202.net Wed Jun 6 07:54:31 2007 From: john-abe at apt202.net (John Cappiello) Date: Wed, 6 Jun 2007 10:54:31 -0400 Subject: [ABE.pm] YAPC.ABE [WAS: Re: self-modifying data structures ] In-Reply-To: <20070606145147.GB9670@knight.manxome.org> References: <300ccfa50706060716h43c58746kfe00c42ed4f8784b@mail.gmail.com> <20070606145147.GB9670@knight.manxome.org> Message-ID: <20070606145431.GE23891@apt202.net> On Wed, Jun 06, 2007 at 10:51:47AM -0400, Ricardo SIGNES wrote: > We just want, maybe, a day of talks, maybe two tracks, and then a big lounge to > hack in. Fully agreed. 2 days tops. /Maybe/ two tracks. We had some ideas about 1 track, and one sort of soft organized hackathon room that ran in parallel. -- jcap From fiedlert at gmail.com Wed Jun 6 13:31:10 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Wed, 6 Jun 2007 16:31:10 -0400 Subject: [ABE.pm] Perl 5.10 rocks Message-ID: <814422ce0706061331u58a14e5fr6dd43cd6707914ca@mail.gmail.com> just to reiterate on damn cool features ... #!/opt/perlbleed/bin/perl use strict; use warnings; use feature ":5.10"; my $isuniq = \&isuniq; while(<>) { given ($_) { when ( /^(\S.*)$/ ) { say "you said $1 ",$isuniq->($1)," times" } default { say "you said nothing ",$isuniq->(qq{nothing})," times" } } } sub isuniq { state %count; return ++$count{$_}{'count'}; } -- The optimist thinks that this is the best of all possible worlds, and the pessimist knows it. -- J. Robert Oppenheimer, "Bulletin of Atomic Scientists" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070606/27e1752f/attachment.html From rjbs-perl-abe at lists.manxome.org Fri Jun 8 14:25:55 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Fri, 8 Jun 2007 17:25:55 -0400 Subject: [ABE.pm] perl 5.10 rules! - stackable -X operators Message-ID: <20070608212555.GA1447@knight> Unix has this program, test(1), which lets you construct simple boolean statements by running a standard unix command that takes weird arguments. It's really clever, and has helped define a lot of conventions. Some of them are enshrined in the "-X" function in perl. You can say, for example: if (-f $file) { unlink $file or die "couldn't unlink file: $!"; } ...and you know that the unlink will only happen if $file is a plain file (it can contain a filename or filehandle). That is: it's not a directory, pipe, fifo, or other weird thing. Of course, now you'll find that sometimes it fails because you don't have write access to the file. So, you write: if (-f $file and -w $file) { unlink $file or die "couldn't unlink file: $!"; } And actually, you only want to delete empty files: if (-f $file and -w $file and -z $file) { unlink $file or die "couldn't unlink file: $!"; } Well, blech. That's ugly. Of course, some of you may now be thinking: "But I can just write this: if (-f $file and -w _ and -z _) { unlink $file or die "couldn't unlink file: $!"; } That's true. Of course, I still says blech, because in 5.10, you can write: if (-f -w -z $file) { unlink $file or die "couldn't unlink file: $!"; } Clearer *and* shorter! Is there anything more Perlish than that combination? (That was a rhetorical question.) -- rjbs From john-abe at apt202.net Fri Jun 8 16:40:28 2007 From: john-abe at apt202.net (John Cappiello) Date: Fri, 8 Jun 2007 19:40:28 -0400 Subject: [ABE.pm] perl 5.10 rules! - stackable -X operators In-Reply-To: <20070608212555.GA1447@knight> References: <20070608212555.GA1447@knight> Message-ID: <20070608234028.GF4012@apt202.net> On Fri, Jun 08, 2007 at 05:25:55PM -0400, Ricardo SIGNES wrote: > if (-f -w -z $file) { > unlink $file or die "couldn't unlink file: $!"; > } Admittedly very cool but I think I would have preferred if (-fwz $file) { -- jcap From faber at linuxnj.com Sun Jun 10 18:38:10 2007 From: faber at linuxnj.com (Faber J. Fedor) Date: Sun, 10 Jun 2007 21:38:10 -0400 Subject: [ABE.pm] YAPC.NA Master Classes Message-ID: <20070611013810.GD14704@neptune.faber.nom> Well, I just learned something about attending YAPCs; don't book your flight until the last minute. I'm interested in taking one of the Master Classes they just announced but to do that I've got to change my returning flight and that change will cost more than the original round-trip tickets! So the Master Class will cost me about $500 all told. Are these guys worth it? I know who they are by reputation but that doesn't tell me if these guys are any good in a classroom or, more importantly, if I'll learn $500 worth of stuff. What do you guys think about these classes? -- Regards, Faber Fedor President Linux New Jersey, Inc. 908-320-0357 800-706-0701 http://www.linuxnj.com From faber at linuxnj.com Sun Jun 10 19:15:07 2007 From: faber at linuxnj.com (Faber J. Fedor) Date: Sun, 10 Jun 2007 22:15:07 -0400 Subject: [ABE.pm] ABE-PM workshop Message-ID: <20070611021507.GB12430@neptune.faber.nom> I like the sound of this idea and don't want it to die, so I'm asking: Are we going to do this thing or not? Shall we discuss it in Houston? -- Regards, Faber Fedor President Linux New Jersey, Inc. 908-320-0357 800-706-0701 http://www.linuxnj.com From rjbs-perl-abe at lists.manxome.org Sun Jun 10 20:10:49 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Sun, 10 Jun 2007 23:10:49 -0400 Subject: [ABE.pm] YAPC.NA Master Classes In-Reply-To: <20070611013810.GD14704@neptune.faber.nom> References: <20070611013810.GD14704@neptune.faber.nom> Message-ID: <20070611031049.GA3918@knight.manxome.org> * "Faber J. Fedor" [2007-06-10T21:38:10] > I'm interested in taking one of the Master Classes they just announced > but to do that I've got to change my returning flight and that change > will cost more than the original round-trip tickets! What does a one-way ticket cost? Would it be cheaper to keep your round-trip and add on a one way? If so, that is nuts! The master class stuff was announced, but then some things came up, leading to the recent changes. > So the Master Class will cost me about $500 all told. Are these guys > worth it? I know who they are by reputation but that doesn't tell me if > these guys are any good in a classroom or, more importantly, if I'll > learn $500 worth of stuff. I've never had a class with Randal or brian, but they're both really good at explaining things, and have been making a living selling classes and books for quite some time. I think all three of those classes look good for you... I think. I'm not sure how much of the Intermedia Perl material you already know and how much you'd be learning. Check out the TOC online and see what you think. PBP and the persistence talk would probably also be of use. -- rjbs From rjbs-perl-abe at lists.manxome.org Sun Jun 10 20:11:32 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Sun, 10 Jun 2007 23:11:32 -0400 Subject: [ABE.pm] ABE-PM workshop In-Reply-To: <20070611021507.GB12430@neptune.faber.nom> References: <20070611021507.GB12430@neptune.faber.nom> Message-ID: <20070611031132.GB3918@knight.manxome.org> * "Faber J. Fedor" [2007-06-10T22:15:07] > I like the sound of this idea and don't want it to die, so I'm asking: > Are we going to do this thing or not? Shall we discuss it in Houston? Let's talk about it more, at the very least. We can talk about it on the plane and at the airport, at least, since also on that flight is Walt, fearless leader of PHL.pm. -- rjbs From rjbs-perl-abe at lists.manxome.org Mon Jun 11 04:22:25 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Mon, 11 Jun 2007 07:22:25 -0400 Subject: [ABE.pm] perl 5.10 rules! - lexical user pragmata Message-ID: <20070611112225.GA4478@knight> That subject line probably sounds a little daunting, but this is actually a pretty simple to use and understand feature. A number of the 5.10 features are about making more things work in a lexical, rather than global or dynamic, scope. One of these things is pragmata, and it's by making lexical pragmata user-writeable that a lot of the others are possible. We know what lexical scope is, and what it means for something to be user-writeable, so then: what's a pragma? Well, there really isn't a clear definition, but here's my suggestion: A pramga is a Perl module that had an effect, possibly in limited duration, upon how the Perl in your program is interpreted. The two most commonly known pragmata are "strict" and "warnings." When strict is in effect, you can't just say "$x = 1;" without declaring $x with (for example) "my." What does "in effect" mean? Well, say we have the following program: use strict; do_something; # strict in effect { no strict; do_something_else; # strict not in effect { do_third_thing; # strict not in effect use strict; do_fourth_thing; # strict in effect } do_final_thing; # strict not in effect } finish_up; # strict in effect Strictures are activated at the line where 'use strict' is given and continue until the end of their lexical scope. They work by futzing with a bitfield value stored in the magic $^H scalar. This wasn't very extensible: there are only so many bitmasks to use, and anyway $^H's implementation wasn't really guaranteed. It's easy to writes modules that go in and out of effect: package Wrex; our $in_effect = 0; sub import { $in_effect = 1; } sub unimport { $in_effect = 0; } If we "use Wrex" then now we can check $Wrex::in_effect and see that it's true. We can "no Wrex" and it's no longer in effect. The problem is that these affect a global state, meaning that once your program has two places that import or unimport Wrex, you're likely to make yourself very confused. To provide a system for user pragmata, perl 5.10 now has added another magic variable: %^H. It's just like $^H, but instead of a bitfield, it's a hash. Further, you can get a reference to the %^H values that were in effect *at any call frame above the current one* by using caller() and checking element ten. You can now rewrite Wrex: package wrex; sub import { $^H{wrex} = 1 } sub unimport { $^H{wrex} = 0 } It's easy to make this actually useful: package Dump; sub import { $^H{Dump} = 1 } sub unimport { $^H{Dump} = 0 } sub dump { my $in_effect = (caller)[10]; return unless $in_effect->{Dump}; shift; # get the class off the stack print "DUMP: @_"; } And in your programs you can write: require Dump; Dump->dump("this won't dump"); use Dump; Dump->dump("this will dump"); { no Dump; Dump->dump("this won't dump either"); } Dump->dump("but this will dump"); As of 5.10, a number of core modules have become lexical. Some of the high-precision math modules like bigint and bigfloat, which can impact performance, can now be limited in scope to where they're really needed. The "less" module, long a joke, now stores information that can tell you what your users want to use less of. if (less->of('memory')) { # use the caches-to-disk branch ... } else { # do it all in RAM } Even if you never write your own lexical pragma, you're pretty likely to benefit from their writability in the glorious 5.10 future. -- rjbs From faber at linuxnj.com Mon Jun 11 06:40:43 2007 From: faber at linuxnj.com (Faber J. Fedor) Date: Mon, 11 Jun 2007 09:40:43 -0400 Subject: [ABE.pm] YAPC.NA Master Classes In-Reply-To: <20070611031049.GA3918@knight.manxome.org> References: <20070611013810.GD14704@neptune.faber.nom> <20070611031049.GA3918@knight.manxome.org> Message-ID: <20070611134043.GA18049@neptune.faber.nom> On 10/06/07 23:10 -0400, Ricardo SIGNES wrote: > * "Faber J. Fedor" [2007-06-10T21:38:10] > > I'm interested in taking one of the Master Classes they just announced > > but to do that I've got to change my returning flight and that change > > will cost more than the original round-trip tickets! > > What does a one-way ticket cost? Would it be cheaper to keep your round-trip > and add on a one way? If so, that is nuts! It turns out a one-way flight (non-stop) costs just as much as my round trip flight or as much as the change to my current flight plan. That's a fracked up business model! > Check out the TOC online and see what you > think. PBP and the persistence talk would probably also be of use. I'll prolly just get the books instead. -- Regards, Faber Fedor President Linux New Jersey, Inc. 908-320-0357 800-706-0701 http://www.linuxnj.com From john-abe at apt202.net Mon Jun 11 11:02:06 2007 From: john-abe at apt202.net (John Cappiello) Date: Mon, 11 Jun 2007 14:02:06 -0400 Subject: [ABE.pm] ABE-PM workshop In-Reply-To: <20070611021507.GB12430@neptune.faber.nom> References: <20070611021507.GB12430@neptune.faber.nom> Message-ID: <20070611180206.GG4012@apt202.net> On Sun, Jun 10, 2007 at 10:15:07PM -0400, Faber J. Fedor wrote: > Shall we discuss it in Houston? Let us never speak of this again. -- jcap From rjbs-perl-abe at lists.manxome.org Thu Jun 14 13:40:24 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Thu, 14 Jun 2007 16:40:24 -0400 Subject: [ABE.pm] job opening: Web Application Developer Message-ID: <20070614204024.GA14331@zodiac.codesimply.com> IC Group is looking for a new programmer for the web interface to our services. You might know us as Pobox.com or Listbox.com; we've been around since before the Internet was cool, offering all kinds of email-related services. We want to bring our web interfaces up to speed with present-day standards and make them more flexible to cope with the future. We're looking for someone who has experience designing and implementing complex web applications. If you're that person: you should know how to write JavaScript -- using reusable libraries like Dojo, MochiKit, etc., not just an onClick here and there. You should know how to write your own reusable code. You should be excited when we tell you that we like to see our code tested and documented. We're a small company located in center city Philadelphia. You'll need to live nearby and come into the office a couple times a week -- but it's a pretty comfortable and casual office, so don't panic. Our software runs on unixy operating systems, uses MySQL for most of its backend storage, and is written primarily in Perl. Familiarity with these would be a big plus, especially if you already know Catalyst or Mason, our primary web frameworks. If not, just show us that you can pick them up quickly. Please send resume (plain text or html preferred, not Word docs) to jobs at icgroup.com. Please include code samples or links to your publically-available code. -- rjbs From rjbs-perl-abe at lists.manxome.org Thu Jun 21 05:32:03 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Thu, 21 Jun 2007 08:32:03 -0400 Subject: [ABE.pm] more reasons to hate mysql Message-ID: <20070621123203.GA486@knight.manxome.org> I just thought I'd share this hate: http://use.perl.org/~rjbs/journal/33570 -- rjbs From tfreedman at iqep.com Fri Jun 29 07:02:01 2007 From: tfreedman at iqep.com (Tom Freedman) Date: Fri, 29 Jun 2007 10:02:01 -0400 Subject: [ABE.pm] July dinner? In-Reply-To: <20070621123203.GA486@knight.manxome.org> References: <20070621123203.GA486@knight.manxome.org> Message-ID: Maybe this is the elephant in the room, but next Wednesday, the first Wednesday of July, is also July 4th. I don't know about you folks, but I plan to be milling around a grill with a beer in my hand at a friend's house. With that in mind, I suggest pushing the July dinner to the second Wednesday of the month, July 11th. Thoughts? Confidentiality Notice: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message. From fiedlert at gmail.com Fri Jun 29 07:25:39 2007 From: fiedlert at gmail.com (Ted Fiedler) Date: Fri, 29 Jun 2007 10:25:39 -0400 Subject: [ABE.pm] July dinner? In-Reply-To: References: <20070621123203.GA486@knight.manxome.org> Message-ID: <814422ce0706290725y3e4ee7cbq63aa833e24080ac9@mail.gmail.com> On 6/29/07, Tom Freedman wrote: > > Maybe this is the elephant in the room, but next Wednesday, the first > Wednesday of July, is also July 4th. I don't know about you folks, but I > plan to be milling around a grill with a beer in my hand at a friend's > house. With that in mind, I suggest pushing the July dinner to the second > Wednesday of the month, July 11th. Im in! Ted -- The optimist thinks that this is the best of all possible worlds, and the pessimist knows it. -- J. Robert Oppenheimer, "Bulletin of Atomic Scientists" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/abe-pm/attachments/20070629/5e903d72/attachment.html From rjbs-perl-abe at lists.manxome.org Fri Jun 29 08:17:00 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Fri, 29 Jun 2007 11:17:00 -0400 Subject: [ABE.pm] July dinner? In-Reply-To: <814422ce0706290725y3e4ee7cbq63aa833e24080ac9@mail.gmail.com> References: <20070621123203.GA486@knight.manxome.org> <814422ce0706290725y3e4ee7cbq63aa833e24080ac9@mail.gmail.com> Message-ID: <20070629151700.GA28590@zodiac.codesimply.com> On 6/29/07, Tom Freedman wrote: >Maybe this is the elephant in the room, but next Wednesday, the first >Wednesday of July, is also July 4th. I don't know about you folks, but I >plan to be milling around a grill with a beer in my hand at a friend's >house. With that in mind, I suggest pushing the July dinner to the second >Wednesday of the month, July 11th. I agree. I meant to send this mail myself, but I just got back from YAPC, which drained me of all initiative. * Ted Fiedler [2007-06-29T10:25:39] > Im in! Tease! -- rjbs From rjbs-perl-abe at lists.manxome.org Sat Jun 30 17:07:38 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Sat, 30 Jun 2007 20:07:38 -0400 Subject: [ABE.pm] perl 5.10 rules! - lexical topic Message-ID: <20070701000738.GA6535@knight.manxome.org> What? Topic? Yeah, you know, the "it" variable: $_ Maybe you've never been bitten by this problem, but it stinks: for (@data) { next if /^#/; next if -d; s/a/b/; sanity_check; print; } ...see the problem? Of course not! It's invisible. See, sanity_check, defined far away, assigns to $_. Since $_ is global, it clobbers what you had in @data, not to mention that it prints the wrong thing. The proper behavior would have been for sanity_check to local-ize $_, but you can't fix it, because you don't control Sanity::Checker. Because of this hard-to-predict bug, some people would prefer you always write: for my $datum (@data) { next if $datum =~ /^#/; next if -d $datum; $datum =~ s/a/b/; sanity_check; print $datu; } ...but that's like fifty more characters, and a bunch more syntax. If you could change your $_ to use a /lexical/ scope, its value would only be set in the current block, and other blocks would keep on using the global $_. You'd write that as: for my $_ (@data) { next if /^#/; next if -d; s/a/b/; sanity_check; print; } In 5.10, this works. -- rjbs From rjbs-perl-abe at lists.manxome.org Sat Jun 30 17:25:25 2007 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Sat, 30 Jun 2007 20:25:25 -0400 Subject: [ABE.pm] local perlmonger news Message-ID: <20070701002525.GA6681@knight.manxome.org> So, as I mentioned earlier, I just got back, Thursday, from YAPC in Houston. It was a great conference, and I had a swell time. Just the right amount of beer, barbeque, and sleep. I learned a few good things and gave some talks that I really enjoyed. I might force one of these (very short) on you, next Wednesday. Faber was there, and can serve as the first non-rjbs ABE.pm member to report back on YAPC. Faber! Was it as fun as I've always said? (Did you see any of my talks? I can't recall.) In other news, Kip is now a father to one more kid! I have no idea whether he'll make it next time (and he isn't on the list), so if necessary, I will show off photos and act proud on his behalf. There's a Perl Workshop in Pittsburgh in October. It's like a 1.5 day YAPC held on the weekend. I'm hoping to get out there. Anybody else interested? http://pghpw.org/ppw2007/ -- rjbs