From moseley at hank.org Fri Apr 5 14:21:15 2013 From: moseley at hank.org (Bill Moseley) Date: Fri, 5 Apr 2013 14:21:15 -0700 Subject: [sf-perl] Sort subroutine didn't return single value at -e line 1. Message-ID: Could someone explain what's happening here with sort? 5.14.2: $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper [uniq 3,1,3,2]' $VAR1 = [ 3, 1, 2 ]; Might be nice to sort those -- like one would do in a shell: $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper [sort uniq 3,1,3,2]' $VAR1 = [ 1, 2, 3, 3 ]; Got an extra value there? That code above was in one of our unit tests, and when I ran with 5.16.1 I then get: $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper [sort uniq 3,1,3,2]' Sort subroutine didn't return single value at -e line 1. This works, though: $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper [uniq sort 3,1,3,2]' $VAR1 = [ 1, 2, 3 ]; -- Bill Moseley moseley at hank.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From hartzell at alerce.com Fri Apr 5 14:44:32 2013 From: hartzell at alerce.com (George Hartzell) Date: Fri, 5 Apr 2013 14:44:32 -0700 Subject: [sf-perl] Sort subroutine didn't return single value at -e line 1. In-Reply-To: References: Message-ID: <20831.17856.373701.2912@gargle.gargle.HOWL> Bill Moseley writes: > Could someone explain what's happening here with sort? > > 5.14.2: > > $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper > [uniq 3,1,3,2]' > $VAR1 = [ > 3, > 1, > 2 > ]; > > Might be nice to sort those -- like one would do in a shell: > > > $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper > [sort uniq 3,1,3,2]' > $VAR1 = [ > 1, > 2, > 3, > 3 > ]; > > > Got an extra value there? > > > That code above was in one of our unit tests, and when I ran with 5.16.1 I > then get: > > > $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper > [sort uniq 3,1,3,2]' > Sort subroutine didn't return single value at -e line 1. > > > This works, though: > > $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper > [uniq sort 3,1,3,2]' > $VAR1 = [ > 1, > 2, > 3 > ]; It seems to be using 'uniq' as it's sorting block. This works perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print \ Dumper [sort {$a <=> $b} uniq (3,1,3,2)]' Not sure *why* yet though. g. From uri at stemsystems.com Fri Apr 5 14:46:47 2013 From: uri at stemsystems.com (Uri Guttman) Date: Fri, 05 Apr 2013 17:46:47 -0400 Subject: [sf-perl] Sort subroutine didn't return single value at -e line 1. In-Reply-To: References: Message-ID: <515F4647.6030006@stemsystems.com> On 04/05/2013 05:21 PM, Bill Moseley wrote: > Could someone explain what's happening here with sort? > > $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper > [sort uniq 3,1,3,2]' > $VAR1 = [ > 1, > 2, > 3, > 3 > ]; > > > Got an extra value there? > > > That code above was in one of our unit tests, and when I ran with 5.16.1 I > then get: > > > $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper > [sort uniq 3,1,3,2]' > Sort subroutine didn't return single value at -e line 1. > > sort takes a sub name for its first arg if that is a bareword. so you are sorting the whole list but using uniq as the comparison function. try putting parens around the list so uniq looks like a sub. or parens around uniq and the list but that is wrong because sort defaults to alpha sorting and that will only work on numbers of the same length. > This works, though: > > $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper > [uniq sort 3,1,3,2]' > $VAR1 = [ > 1, > 2, > 3 > ]; > > well, that is wrong for the same reason as i said above. try it with 10 also. uri > > > > _______________________________________________ > SanFrancisco-pm mailing list > SanFrancisco-pm at pm.org > http://mail.pm.org/mailman/listinfo/sanfrancisco-pm > From hartzell at alerce.com Fri Apr 5 14:57:21 2013 From: hartzell at alerce.com (George Hartzell) Date: Fri, 5 Apr 2013 14:57:21 -0700 Subject: [sf-perl] Sort subroutine didn't return single value at -e line 1. In-Reply-To: <20831.17856.373701.2912@gargle.gargle.HOWL> References: <20831.17856.373701.2912@gargle.gargle.HOWL> Message-ID: <20831.18625.246596.613399@gargle.gargle.HOWL> George Hartzell writes: > [...] > It seems to be using 'uniq' as it's sorting block. > > This works > > perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print \ > Dumper [sort {$a <=> $b} uniq (3,1,3,2)]' > > Not sure *why* yet though. Ah, there it is. First line of perldoc -f sort sort SUBNAME LIST You can specify a subname to use as the pairwise sorting function. g. From moseley at hank.org Fri Apr 5 15:13:58 2013 From: moseley at hank.org (Bill Moseley) Date: Fri, 5 Apr 2013 15:13:58 -0700 Subject: [sf-perl] Sort subroutine didn't return single value at -e line 1. In-Reply-To: <515F4647.6030006@stemsystems.com> References: <515F4647.6030006@stemsystems.com> Message-ID: On Fri, Apr 5, 2013 at 2:46 PM, Uri Guttman wrote: > > sort takes a sub name for its first arg if that is a bareword. so you are > sorting the whole list but using uniq as the comparison function. > > try putting parens around the list so uniq looks like a sub. or parens > around uniq and the list but that is wrong because sort defaults to alpha > sorting and that will only work on numbers of the same length. Oh, I had tried parens, but I guess it's still seen as a barword. $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper [sort uniq( 3,1,3,2)]' $VAR1 = [ 1, 2, 3, 3 ]; as well as "sort (uniq 3,1,3,2)" Does the plus sign tell sort it's not a bareword in this case? $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper [sort +uniq 3,1,3,2]' $VAR1 = [ 1, 2, 3 ]; Yes, still need to deal with the numeric sort, but I was just using that list as an example. -- Bill Moseley moseley at hank.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From hartzell at alerce.com Fri Apr 5 15:49:03 2013 From: hartzell at alerce.com (George Hartzell) Date: Fri, 5 Apr 2013 15:49:03 -0700 Subject: [sf-perl] Logging: per-object, per-package, kinda-global? Message-ID: <20831.21727.104669.918161@gargle.gargle.HOWL> Hi All, We can all agree that globals are evil, right? (you there in back, put your hand down, I'm trying to make a point...). I'm looking at logging and am (once again) playing with a couple of the strategies that package on CPAN enable. On the one hand I can simply give each of my classes a logger attribute and pass one in on construction, or use a default. Works reasonably well with any of the packages I'm looking at (::Log4j, ::Dispatchouli). It's kind of a pain to always be passing them into constructors and (while not a problem for this particular project) it could be a scaling problem. On the other hand I could use Log::Any to generate a package specific logger, backed by any of the various Log::Any::Adapter::* packages. On the gripping hand, I could use Log::Dispatchouli::Global, which I only recently came to understand. I'd dismissed it earlier because I thought is simply declared a global logger. It's tricky (and I was wrong), one creates a subclass of Log::Dispatchouli::Global and uses that. This effectively generates a global within a namespace that one controls, so other packages are unlikely to step on it. I can probably guess how Jon (the Log::Any author) will vote. What approach are others among you using? g. From uri at stemsystems.com Fri Apr 5 17:13:13 2013 From: uri at stemsystems.com (Uri Guttman) Date: Fri, 05 Apr 2013 20:13:13 -0400 Subject: [sf-perl] Sort subroutine didn't return single value at -e line 1. In-Reply-To: References: <515F4647.6030006@stemsystems.com> Message-ID: <515F6899.4020409@stemsystems.com> On 04/05/2013 06:13 PM, Bill Moseley wrote: > On Fri, Apr 5, 2013 at 2:46 PM, Uri Guttman wrote: > >> >> sort takes a sub name for its first arg if that is a bareword. so you are >> sorting the whole list but using uniq as the comparison function. >> >> try putting parens around the list so uniq looks like a sub. or parens >> around uniq and the list but that is wrong because sort defaults to alpha >> sorting and that will only work on numbers of the same length. > > > Oh, I had tried parens, but I guess it's still seen as a barword. > > $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper > [sort uniq( 3,1,3,2)]' > $VAR1 = [ > 1, > 2, > 3, > 3 > ]; > > as well as "sort (uniq 3,1,3,2)" seems to be parsed that way. > > > > Does the plus sign tell sort it's not a bareword in this case? > > $ perl -wle 'use Data::Dumper; use List::MoreUtils "uniq"; print Dumper > [sort +uniq 3,1,3,2]' > $VAR1 = [ > 1, > 2, > 3 > ]; > yes. you can always make any bareword into a function call with a preceding plus. it is a noop from a semantic view but it lets the parser know it is an expression and not a bareword. > Yes, still need to deal with the numeric sort, but I was just using that > list as an example. if you had the numeric comparison block as you know about, this problem would never have surfaced. using good example data is important too. uri From extasia at extasia.org Fri Apr 5 17:15:48 2013 From: extasia at extasia.org (David Alban) Date: Fri, 5 Apr 2013 17:15:48 -0700 Subject: [sf-perl] globals Message-ID: On Fri, Apr 5, 2013 at 3:49 PM, George Hartzell wrote: > We can all agree that globals are evil, right? (you there in back, > put your hand down, I'm trying to make a point...). how about if i change the Subject field? :-) i'm quite happy to use global "constants" i declare using the Readonly module. i'm curious to know if anyone thinks that's a bad idea. -- Live in a world of your own, but always welcome visitors. *** Rule of law isn't for everyone. http://www.amazon.com/Liberty-Justice-Some-Equality-Powerful/dp/0805092056 From jeff at imaginative-software.com Fri Apr 5 20:58:19 2013 From: jeff at imaginative-software.com (Jeffrey Ryan Thalhammer) Date: Fri, 5 Apr 2013 20:58:19 -0700 Subject: [sf-perl] Logging: per-object, per-package, kinda-global? In-Reply-To: <20831.21727.104669.918161@gargle.gargle.HOWL> References: <20831.21727.104669.918161@gargle.gargle.HOWL> Message-ID: <2A35E39D-7FD3-4758-BBAE-A6789E0BF15B@imaginative-software.com> On Apr 5, 2013, at 3:49 PM, George Hartzell wrote: > We can all agree that globals are evil, right? (you there in back, > put your hand down, I'm trying to make a point...). > > I'm looking at logging and am (once again) playing with a couple of > the strategies that package on CPAN enable. I had the same dilemma with Pinto. I wanted to log stuff from any and all objects, but I didn't want a singleton or global logger. So I ended up passing loggers to all the constructors. I used a role (called "Loggable") to help make each class uniform. But I never really liked having to pass that damn logger object all over the place. I was using the logger as my chrome too -- to display diagnostic messages to the user. But then I realized the user really has no interest in the messages from all those low-level classes. There were only a handful of classes that could produce any kind of user-friendly message. I still pass around the logger to each constructor, but only for a few classes now. And instead of logging, the low-level classes just have a simple debug() function that spits messages to STDERR only if PINTO_DEBUG is set. So I've sacrificed some (probably unnecessary) power & flexibility in exchange for simpler, cleaner code. Your mileage may vary. -Jeff From jeff at imaginative-software.com Fri Apr 5 21:08:06 2013 From: jeff at imaginative-software.com (Jeffrey Ryan Thalhammer) Date: Fri, 5 Apr 2013 21:08:06 -0700 Subject: [sf-perl] globals In-Reply-To: References: Message-ID: On Apr 5, 2013, at 5:15 PM, David Alban wrote: > i'm quite happy to use global "constants" i declare using the Readonly > module. i'm curious to know if anyone thinks that's a bad idea. Sounds fine to me. I do it all the time (see Pinto::Constants). And on very rare occasions, I do use global variables (see Pinto::Globals) but only to help facilitate testing. Of course, everyone has an opinion on exactly *how* you create a constant in Perl, but that's another story. -Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: From cpan at goess.org Sat Apr 6 08:26:02 2013 From: cpan at goess.org (Kevin Goess) Date: Sat, 6 Apr 2013 08:26:02 -0700 Subject: [sf-perl] Logging: per-object, per-package, kinda-global? In-Reply-To: <2A35E39D-7FD3-4758-BBAE-A6789E0BF15B@imaginative-software.com> References: <20831.21727.104669.918161@gargle.gargle.HOWL> <2A35E39D-7FD3-4758-BBAE-A6789E0BF15B@imaginative-software.com> Message-ID: > > > I had the same dilemma with Pinto. I wanted to log stuff from any and all > objects, but I didn't want a singleton or global logger. So I ended up > passing loggers to all the constructors. I used a role (called "Loggable") > to help make each class uniform. But I never really liked having to pass > that damn logger object all over the place. > > The last couple codebases I've worked on, I've set it up so you can do Log->info("whatever") and that "Log" class uses AUTOLOAD to catch the method gets the log4perl logger based on the caller's package something like this my $logger = Log::Log4perl::get_logger($caller); $logger->$levelname(grep {defined $_ } @args); That keeps the infrastructure code you have to look at in your own stuff to a minimum. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hartzell at alerce.com Thu Apr 11 11:36:29 2013 From: hartzell at alerce.com (George Hartzell) Date: Thu, 11 Apr 2013 11:36:29 -0700 Subject: [sf-perl] Anyone know of anything like File::Size::Human? Message-ID: <20839.685.378948.551360@gargle.gargle.HOWL> I'd like to convert strings like 100KB or 2TB into the appropriate numbers (102400 bytes, etc..). In the long run I'd also like to convert comparison operators into subroutines that test that operator, e.g. '> 100KB' becomes my $test = sub { return -s $_[0] > 102400 } or something similar (untested example...). Seems like this must already be sitting on a disk somewhere. Anyone seen it? g. From hartzell at alerce.com Thu Apr 11 12:40:21 2013 From: hartzell at alerce.com (George Hartzell) Date: Thu, 11 Apr 2013 12:40:21 -0700 Subject: [sf-perl] Anyone know of anything like File::Size::Human? In-Reply-To: <20839.685.378948.551360@gargle.gargle.HOWL> References: <20839.685.378948.551360@gargle.gargle.HOWL> Message-ID: <20839.4517.601305.793838@gargle.gargle.HOWL> David Golden's Path::Iterator::Rule pointed me to Number::Compare which tastes great and is less filling. g. From jeff at imaginative-software.com Thu Apr 11 13:10:45 2013 From: jeff at imaginative-software.com (Jeffrey Ryan Thalhammer) Date: Thu, 11 Apr 2013 13:10:45 -0700 Subject: [sf-perl] Crowd Funding For Pinto Message-ID: Hey everyone- brian d foy has been experimenting with crowd-funding for open source projects, so I approached him about running a campaign for Pinto. I made a short video and we launched the campaign on Crowdtilt (which happens to be Perl shop). I'd really appreciate if you could help spread the word! Contributions are good too :) Here's the campaign: http://tinyurl.com/gopinto Pinto is a powerful application for creating and managing custom repositories of Perl modules. You can use any combination of CPAN modules and private modules. And the repository works seamlessly with installer clients like cpan and cpanm. When you build up your system from a Pinto repository, you'll get exactly the modules you want and the versions you want -- every time. Pinto also has some novel tools for helping you manage and track upgrades to your dependencies The funds from the campaign will be used to enhance Pinto to fetch specific versions of CPAN modules (without you having to know which distribution they came from). That will make is easy to build up a repository that contains all the modules needed for your legacy environment. Thanks, -Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: From ddascalescu at gmail.com Fri Apr 12 02:39:33 2013 From: ddascalescu at gmail.com (Dan Dascalescu) Date: Fri, 12 Apr 2013 02:39:33 -0700 Subject: [sf-perl] Crowd Funding For Pinto In-Reply-To: References: Message-ID: Just wanted to day that I'm very pleasantly surprised at the amount of funding that a somewhat obscure (to my perception) project like Pinto got. I used to be more active in the Perl community a few years ago, and now I still use Perl for scripting, but much less often than Meteor (the really cool Node.JS real-time web app framework). Anyhow, glad to see Perl is definitely not dead. -- Dan Dascalescu CIO, *Blueseed *, the visa-free startup incubator On Thu, Apr 11, 2013 at 1:10 PM, Jeffrey Ryan Thalhammer < jeff at imaginative-software.com> wrote: > Hey everyone- > > brian d foy has been experimenting with crowd-funding for open source > projects, so I approached him about running a campaign for Pinto. > I made a short video and we launched the campaign on Crowdtilt (which > happens to be Perl shop). I'd really appreciate if you could help spread > the word! Contributions are good too :) > > Here's the campaign: http://tinyurl.com/gopinto > > Pinto is a powerful application for > creating and managing custom repositories of Perl modules. You can use any > combination of CPAN modules and private modules. And the repository works > seamlessly with installer clients like cpan and cpanm. > > When you build up your system from a Pinto repository, you'll get exactly > the modules you want and the versions you want -- every time. Pinto also > has some novel tools for helping you manage and track upgrades to your > dependencies > > The funds from the campaign will be used to enhance Pinto to fetch > specific versions of CPAN modules (without you having to know which > distribution they came from). That will make is easy to build up a > repository that contains all the modules needed for your legacy > environment. > Thanks, > > -Jeff > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeff at imaginative-software.com Fri Apr 12 10:44:07 2013 From: jeff at imaginative-software.com (Jeffrey Ryan Thalhammer) Date: Fri, 12 Apr 2013 10:44:07 -0700 Subject: [sf-perl] Crowd Funding For Pinto In-Reply-To: References: Message-ID: On Apr 12, 2013, at 2:39 AM, Dan Dascalescu wrote: > Just wanted to say that I'm very pleasantly surprised at the amount of funding that a somewhat obscure (to my perception) project like Pinto got. I used to be more active in the Perl community a few years ago, and now I still use Perl for scripting, but much less often than Meteor (the really cool Node.JS real-time web app framework). Anyhow, glad to see Perl is definitely not dead. Pinto is still a young project. It started while I was consulting for Genentech in 2010, and I've continued working on it since then. Stratopan is a new business for hosting repositories of Perl modules that we're building on top of Pinto (imagine GitHub for Perl modules). I don't expect Stratopan to ever become a $100M enterprise -- not like the projects you'll have at Blueseed (very cool, by the way). But Perl is used in nearly every major business in some way or another. Many of them are legacy systems, but those are often the systems that pay most of the bills. Perl doesn't enjoy the buzz it once had because there are so many other voices in the room now (Ruby, Python, Node, etc.). But it's definitely not dead. -Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: From cpan at goess.org Sun Apr 14 10:56:52 2013 From: cpan at goess.org (Kevin Goess) Date: Sun, 14 Apr 2013 10:56:52 -0700 Subject: [sf-perl] Anyone know of anything like File::Size::Human? Message-ID: I just recently found Number::Bytes::Human on CPAN, wanted to point that out. http://search.cpan.org/~dagobert/Number-Bytes-Human-0.09/Human.pm ---------- Forwarded message ---------- From: George Hartzell Date: Thu, Apr 11, 2013 at 12:40 PM Subject: Re: [sf-perl] Anyone know of anything like File::Size::Human? To: hartzell at alerce.com Cc: "SF.pm" David Golden's Path::Iterator::Rule pointed me to Number::Compare which tastes great and is less filling. g. _______________________________________________ SanFrancisco-pm mailing list SanFrancisco-pm at pm.org http://mail.pm.org/mailman/listinfo/sanfrancisco-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeff at imaginative-software.com Mon Apr 15 14:47:48 2013 From: jeff at imaginative-software.com (Jeffrey Ryan Thalhammer) Date: Mon, 15 Apr 2013 14:47:48 -0700 Subject: [sf-perl] [LA.pm] [LA.PM] Bringing a Hackerspace to South L.A. In-Reply-To: References: Message-ID: <5C29A56A-C7C1-4760-A41C-5F12C3642909@imaginative-software.com> The technology industry has been really good to me. The least I can do is lend a hand to the next generation. Please join me and cast a vote for Miguel and UrbanTxT... http://myla2050.maker.good.is/projects/urbantxt And while you're at it, send a tweet about @UrbanTxT too. Time is running out. Do it now! -Jeff On Apr 15, 2013, at 8:56 AM, Miguel Hernandez wrote: > Howdy folks. > > I spoke with some of y'all at SCALE this year about how I'm working on bringing more technology resources to South Central L.A. Part of that is bringing a hackerspace to a traditionally under-served area. More than that, we envision it as a community center built around technology- machines running Linux, training kids & teens how to program & exposing people of ALL ages to open source software, etc. But we need YOUR help to do it! We've made a submission to the LA2050 contest where we could win 1 of 10 grants worth $100,000 to make this vision a reality. > > Please visit the link below, create an account & vote for us. You'll receive an email asking you to confirm your vote so please do so. There's a little over 48 hours before the voting period ends. > http://myla2050.maker.good.is/projects/urbantxt > > If you feel it a worthwhile endeavor, it'd be great if you could also share it with your social networks. If so, you can tweet @UrbanTxT & @Techivist (me) with the #Hackaneer hashtag. > > Thanks in Advance! > --miguel > > p.s. We just had South LA's 2nd Hackathon event this past Saturday where we taught kids how to program with Scratch, continued building a community resource guide/website & a bunch of other cool things. Comment below if you'd like to see links to photos of the event, etc. :) > _______________________________________________ > Losangeles-pm mailing list > Losangeles-pm at pm.org > http://mail.pm.org/mailman/listinfo/losangeles-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From hartzell at alerce.com Mon Apr 22 16:19:58 2013 From: hartzell at alerce.com (George Hartzell) Date: Mon, 22 Apr 2013 16:19:58 -0700 Subject: [sf-perl] aliases, confusion, and me.... Message-ID: <20853.50590.111978.425696@gargle.gargle.HOWL> Given the following little bit of code. use strict; use warnings; use Test::More; { package Poodle; sub new { return bless {} => __PACKAGE__; } sub this { my $self = shift; $self->{foo} } sub that { $_[0]->{foo} } sub the_other { $_[0]{foo} } } my $p = Poodle->new(); $p->{foo} = 10; is( $p->{foo}, 10, 'reaching into hash worked' ); is( $p->this, 10, 'self works' ); is( $p->that, 10, 'proper dreferencing of alias worked' ); is( $p->the_other, 10, 'HUH?' ); done_testing; and looking at the methods "this", "that", and "the other". I consider "this" to be the "right" way to write a method [or something like this: "my ($self) = @_;" instead of the shift...] I often see and sometimes use the technique illustrated in "that", where one directly accesses the alias in the arguments. I thought I understood the implications of it being an aliases to the value being passed in. I was stumped as to why "the_other" works. I figured that it must be some little subtlety of aliases and argument list and dusty language corners. Then I used: perl -MO=Deparse ~/tmp/ape.pl to look at how perl's parsing it. ... sub that { use warnings; use strict; $_[0]{'foo'}; } sub the_other { use warnings; use strict; $_[0]{'foo'}; } ... While I now understand why "that" and "the_other" work identically, I now _do not_ understand why perl's handling them the way that it is. The same phenomena occurs in a class based on a blessed array ref. Can anyone explain what's going on? Thanks, g. From frimicc at gmail.com Mon Apr 22 16:29:27 2013 From: frimicc at gmail.com (Michael Friedman) Date: Mon, 22 Apr 2013 16:29:27 -0700 Subject: [sf-perl] aliases, confusion, and me.... In-Reply-To: <20853.50590.111978.425696@gargle.gargle.HOWL> References: <20853.50590.111978.425696@gargle.gargle.HOWL> Message-ID: The arrows are optional when you are using multiple subscripts. See http://stackoverflow.com/questions/2475042/nested-dereferencing-arrows-in-perl-to-omit-or-not-to-omit The key phrase being, "Subscripts next to subscripts imply references," so you don't need to explain to the parser that you are officially dereferencing, which is what the arrow operator does. Note that this won't work with $self{foo} instead of $self->{foo} because you only have a single subscript there vs. [0]{foo}. -- Mike Friedman On Apr 22, 2013, at 4:19 PM, George Hartzell wrote: > > Given the following little bit of code. > > use strict; > use warnings; > > use Test::More; > > { > package Poodle; > sub new { return bless {} => __PACKAGE__; } > sub this { my $self = shift; $self->{foo} } > sub that { $_[0]->{foo} } > sub the_other { $_[0]{foo} } > } > > my $p = Poodle->new(); > $p->{foo} = 10; > > is( $p->{foo}, 10, 'reaching into hash worked' ); > is( $p->this, 10, 'self works' ); > is( $p->that, 10, 'proper dreferencing of alias worked' ); > is( $p->the_other, 10, 'HUH?' ); > > done_testing; > > and looking at the methods "this", "that", and "the other". > > I consider "this" to be the "right" way to write a method [or > something like this: "my ($self) = @_;" instead of the shift...] > > I often see and sometimes use the technique illustrated in "that", > where one directly accesses the alias in the arguments. I thought I > understood the implications of it being an aliases to the value being > passed in. > > I was stumped as to why "the_other" works. I figured that it must be > some little subtlety of aliases and argument list and dusty language > corners. > > Then I used: > > perl -MO=Deparse ~/tmp/ape.pl > > to look at how perl's parsing it. > > ... > sub that { > use warnings; > use strict; > $_[0]{'foo'}; > } > sub the_other { > use warnings; > use strict; > $_[0]{'foo'}; > } > ... > > While I now understand why "that" and "the_other" work identically, I > now _do not_ understand why perl's handling them the way that it is. > > The same phenomena occurs in a class based on a blessed array ref. > > Can anyone explain what's going on? > > Thanks, > > g. > _______________________________________________ > SanFrancisco-pm mailing list > SanFrancisco-pm at pm.org > http://mail.pm.org/mailman/listinfo/sanfrancisco-pm From hartzell at alerce.com Mon Apr 22 16:50:39 2013 From: hartzell at alerce.com (George Hartzell) Date: Mon, 22 Apr 2013 16:50:39 -0700 Subject: [sf-perl] aliases, confusion, and me.... In-Reply-To: References: <20853.50590.111978.425696@gargle.gargle.HOWL> Message-ID: <20853.52431.259159.446118@gargle.gargle.HOWL> Doh. I *knew* that, from the days of nasty nested data structures.... use strict; use warnings; use Test::More; my $a = { a => { b => { c => 'wow' } } }; is( $a->{a}->{b}->{c}, 'wow', 'wow...' ); is( $a->{a}{b}{c}, 'wow', 'wow...' ); done_testing; Thanks for the quick response, g. Michael Friedman writes: > The arrows are optional when you are using multiple subscripts. See > http://stackoverflow.com/questions/2475042/nested-dereferencing-arrows-in-perl-to-omit-or-not-to-omit > > The key phrase being, "Subscripts next to subscripts imply references," so you don't need to explain to the parser that you are officially dereferencing, which is what the arrow operator does. > > Note that this won't work with $self{foo} instead of $self->{foo} because you only have a single subscript there vs. [0]{foo}. > > -- Mike Friedman > > On Apr 22, 2013, at 4:19 PM, George Hartzell wrote: > > > > > Given the following little bit of code. > > > > use strict; > > use warnings; > > > > use Test::More; > > > > { > > package Poodle; > > sub new { return bless {} => __PACKAGE__; } > > sub this { my $self = shift; $self->{foo} } > > sub that { $_[0]->{foo} } > > sub the_other { $_[0]{foo} } > > } > > > > my $p = Poodle->new(); > > $p->{foo} = 10; > > > > is( $p->{foo}, 10, 'reaching into hash worked' ); > > is( $p->this, 10, 'self works' ); > > is( $p->that, 10, 'proper dreferencing of alias worked' ); > > is( $p->the_other, 10, 'HUH?' ); > > > > done_testing; > > > > and looking at the methods "this", "that", and "the other". > > > > I consider "this" to be the "right" way to write a method [or > > something like this: "my ($self) = @_;" instead of the shift...] > > > > I often see and sometimes use the technique illustrated in "that", > > where one directly accesses the alias in the arguments. I thought I > > understood the implications of it being an aliases to the value being > > passed in. > > > > I was stumped as to why "the_other" works. I figured that it must be > > some little subtlety of aliases and argument list and dusty language > > corners. > > > > Then I used: > > > > perl -MO=Deparse ~/tmp/ape.pl > > > > to look at how perl's parsing it. > > > > ... > > sub that { > > use warnings; > > use strict; > > $_[0]{'foo'}; > > } > > sub the_other { > > use warnings; > > use strict; > > $_[0]{'foo'}; > > } > > ... > > > > While I now understand why "that" and "the_other" work identically, I > > now _do not_ understand why perl's handling them the way that it is. > > > > The same phenomena occurs in a class based on a blessed array ref. > > > > Can anyone explain what's going on? > > > > Thanks, > > > > g. > > _______________________________________________ > > SanFrancisco-pm mailing list > > SanFrancisco-pm at pm.org > > http://mail.pm.org/mailman/listinfo/sanfrancisco-pm From frimicc at gmail.com Mon Apr 22 16:56:04 2013 From: frimicc at gmail.com (Michael Friedman) Date: Mon, 22 Apr 2013 16:56:04 -0700 Subject: [sf-perl] aliases, confusion, and me.... In-Reply-To: <20853.52431.259159.446118@gargle.gargle.HOWL> References: <20853.50590.111978.425696@gargle.gargle.HOWL> <20853.52431.259159.446118@gargle.gargle.HOWL> Message-ID: "from the days of..." You mean we aren't still using nasty nested data structures anymore? ;-) On Apr 22, 2013, at 4:50 PM, George Hartzell wrote: > > Doh. I *knew* that, from the days of nasty nested data > structures.... > > use strict; > use warnings; > > use Test::More; > > my $a = { a => { b => { c => 'wow' } } }; > > is( $a->{a}->{b}->{c}, 'wow', 'wow...' ); > is( $a->{a}{b}{c}, 'wow', 'wow...' ); > > done_testing; > > Thanks for the quick response, > > g. > > Michael Friedman writes: >> The arrows are optional when you are using multiple subscripts. See >> http://stackoverflow.com/questions/2475042/nested-dereferencing-arrows-in-perl-to-omit-or-not-to-omit >> >> The key phrase being, "Subscripts next to subscripts imply references," so you don't need to explain to the parser that you are officially dereferencing, which is what the arrow operator does. >> >> Note that this won't work with $self{foo} instead of $self->{foo} because you only have a single subscript there vs. [0]{foo}. >> >> -- Mike Friedman >> >> On Apr 22, 2013, at 4:19 PM, George Hartzell wrote: >> >>> >>> Given the following little bit of code. >>> >>> use strict; >>> use warnings; >>> >>> use Test::More; >>> >>> { >>> package Poodle; >>> sub new { return bless {} => __PACKAGE__; } >>> sub this { my $self = shift; $self->{foo} } >>> sub that { $_[0]->{foo} } >>> sub the_other { $_[0]{foo} } >>> } >>> >>> my $p = Poodle->new(); >>> $p->{foo} = 10; >>> >>> is( $p->{foo}, 10, 'reaching into hash worked' ); >>> is( $p->this, 10, 'self works' ); >>> is( $p->that, 10, 'proper dreferencing of alias worked' ); >>> is( $p->the_other, 10, 'HUH?' ); >>> >>> done_testing; >>> >>> and looking at the methods "this", "that", and "the other". >>> >>> I consider "this" to be the "right" way to write a method [or >>> something like this: "my ($self) = @_;" instead of the shift...] >>> >>> I often see and sometimes use the technique illustrated in "that", >>> where one directly accesses the alias in the arguments. I thought I >>> understood the implications of it being an aliases to the value being >>> passed in. >>> >>> I was stumped as to why "the_other" works. I figured that it must be >>> some little subtlety of aliases and argument list and dusty language >>> corners. >>> >>> Then I used: >>> >>> perl -MO=Deparse ~/tmp/ape.pl >>> >>> to look at how perl's parsing it. >>> >>> ... >>> sub that { >>> use warnings; >>> use strict; >>> $_[0]{'foo'}; >>> } >>> sub the_other { >>> use warnings; >>> use strict; >>> $_[0]{'foo'}; >>> } >>> ... >>> >>> While I now understand why "that" and "the_other" work identically, I >>> now _do not_ understand why perl's handling them the way that it is. >>> >>> The same phenomena occurs in a class based on a blessed array ref. >>> >>> Can anyone explain what's going on? >>> >>> Thanks, >>> >>> g. >>> _______________________________________________ >>> SanFrancisco-pm mailing list >>> SanFrancisco-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm From hartzell at alerce.com Mon Apr 22 16:59:54 2013 From: hartzell at alerce.com (George Hartzell) Date: Mon, 22 Apr 2013 16:59:54 -0700 Subject: [sf-perl] aliases, confusion, and me.... In-Reply-To: References: <20853.50590.111978.425696@gargle.gargle.HOWL> <20853.52431.259159.446118@gargle.gargle.HOWL> Message-ID: <20853.52986.786945.84678@gargle.gargle.HOWL> Not at all. Errr, I mean, "Who, me?". I should have said "from back in the days when I got my head around the concept...". g. Michael Friedman writes: > "from the days of..." You mean we aren't still using nasty nested > data structures anymore? ;-) > > > On Apr 22, 2013, at 4:50 PM, George Hartzell wrote: > > > > > Doh. I *knew* that, from the days of nasty nested data > > structures.... > > > > use strict; > > use warnings; > > > > use Test::More; > > > > my $a = { a => { b => { c => 'wow' } } }; > > > > is( $a->{a}->{b}->{c}, 'wow', 'wow...' ); > > is( $a->{a}{b}{c}, 'wow', 'wow...' ); > > > > done_testing; > > > > Thanks for the quick response, > > > > g. > > > > Michael Friedman writes: > >> The arrows are optional when you are using multiple subscripts. See > >> http://stackoverflow.com/questions/2475042/nested-dereferencing-arrows-in-perl-to-omit-or-not-to-omit > >> > >> The key phrase being, "Subscripts next to subscripts imply references," so you don't need to explain to the parser that you are officially dereferencing, which is what the arrow operator does. > >> > >> Note that this won't work with $self{foo} instead of $self->{foo} because you only have a single subscript there vs. [0]{foo}. > >> > >> -- Mike Friedman > >> > >> On Apr 22, 2013, at 4:19 PM, George Hartzell wrote: > >> > >>> > >>> Given the following little bit of code. > >>> > >>> use strict; > >>> use warnings; > >>> > >>> use Test::More; > >>> > >>> { > >>> package Poodle; > >>> sub new { return bless {} => __PACKAGE__; } > >>> sub this { my $self = shift; $self->{foo} } > >>> sub that { $_[0]->{foo} } > >>> sub the_other { $_[0]{foo} } > >>> } > >>> > >>> my $p = Poodle->new(); > >>> $p->{foo} = 10; > >>> > >>> is( $p->{foo}, 10, 'reaching into hash worked' ); > >>> is( $p->this, 10, 'self works' ); > >>> is( $p->that, 10, 'proper dreferencing of alias worked' ); > >>> is( $p->the_other, 10, 'HUH?' ); > >>> > >>> done_testing; > >>> > >>> and looking at the methods "this", "that", and "the other". > >>> > >>> I consider "this" to be the "right" way to write a method [or > >>> something like this: "my ($self) = @_;" instead of the shift...] > >>> > >>> I often see and sometimes use the technique illustrated in "that", > >>> where one directly accesses the alias in the arguments. I thought I > >>> understood the implications of it being an aliases to the value being > >>> passed in. > >>> > >>> I was stumped as to why "the_other" works. I figured that it must be > >>> some little subtlety of aliases and argument list and dusty language > >>> corners. > >>> > >>> Then I used: > >>> > >>> perl -MO=Deparse ~/tmp/ape.pl > >>> > >>> to look at how perl's parsing it. > >>> > >>> ... > >>> sub that { > >>> use warnings; > >>> use strict; > >>> $_[0]{'foo'}; > >>> } > >>> sub the_other { > >>> use warnings; > >>> use strict; > >>> $_[0]{'foo'}; > >>> } > >>> ... > >>> > >>> While I now understand why "that" and "the_other" work identically, I > >>> now _do not_ understand why perl's handling them the way that it is. > >>> > >>> The same phenomena occurs in a class based on a blessed array ref. > >>> > >>> Can anyone explain what's going on? > >>> > >>> Thanks, > >>> > >>> g. > >>> _______________________________________________ > >>> SanFrancisco-pm mailing list > >>> SanFrancisco-pm at pm.org > >>> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm From sfpm at vmbrasseur.com Tue Apr 23 09:54:59 2013 From: sfpm at vmbrasseur.com (VM Brasseur) Date: Tue, 23 Apr 2013 09:54:59 -0700 Subject: [sf-perl] [jobs] East Coast Perl shop opening an SF office Message-ID: <5176BCE3.2030300@vmbrasseur.com> Hey there, gang! Long time no see. Gotta get myself back to an SF.pm meeting some time in the near future but, well...life. It happens. In the meantime though... A friend of mine has recruited me to recruit [0] for the company he works for. It's a mid-size, stable [1] company on the East Coast. While--like any software of decent age--it has elements written in Python, Ruby, Node.js and other languages, the primary language they use for their software is Perl.[2] They think it's pretty swell and, really, who can blame them? This company will be opening an office in San Francisco in the next couple of months and, realizing that I know a lot of great Perlers, my friend at the company has asked me to help them find some people to help build the SF team. Their preference is for NICE people who know and love Perl and (ideally but not a deal breaker) who also have some experience on the front end (JS). People who don't know Perl but do know some other high-level scripting language are also welcome.[3] The salary is SF-norm; the benefits are top notch; the people are smart and helpful; the company is laid back yet innovative; the hours are "have a real life" sane, not startup ridiculous. If you're interested--or know someone else who may be--drop me a line! Please reply to me directly (vmb at shoeless-consulting.com or sfpm at vmbrasseur.com) rather than to the list. No one needs the extra noise in their inbox. Thanks, all! --VM Brasseur @vmbrasseur [0] Does that make it meta-recruiting? [1] ~10 years old and still growing [2] Modern Perl, not 5.8. HTML::Mason, Dancer, TDD, pair programming, that sort of thing. [3] The key qualities they look for are ability and humanity. They realize they can teach anyone Perl but they can't teach someone how not to be an asshole. -- shoeless consulting good doesn't have to be formal http://shoeless-consulting.com From jeff at stratopan.com Mon Apr 29 08:59:14 2013 From: jeff at stratopan.com (Jeffrey Ryan Thalhammer) Date: Mon, 29 Apr 2013 08:59:14 -0700 Subject: [sf-perl] [Announcement] You Are Invited To The Stratopan Beta Message-ID: <895EF4A1-9353-44BF-B808-0F1570FA53CC@stratopan.com> Hey San Francisco Perlers- Stratopan is a new service for hosting custom repositories of Perl modules in the cloud. Private beta trials will begin early this summer. If you'd like to participate in the trials, please stop by https://stratopan.com and leave us your email address. We'll contact you with all the details when the trials begin. Stratopan will host both public and private repositories with any combination of proprietary and open source Perl modules. And Stratopan is built on Pinto, the open source tool for creating custom CPAN-like repositories, so it has the same helpful tools for managing your application dependencies. Cheers! -Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: