In a message dated Fri, 12 Apr 2002, Luke Palmer writes: > Couldn't you do it with old-style Perl5 subs? > > sub printRec { > my $p = chomp(shift // $_); > print ":$_:\n" > } > > Or am _I_ missing something?
That definitely won't work (aside from the $p/$_ swap which I assume is unintentional), because $_ is now lexical. If my understanding is correct and $_ is always the topic, and the first parameter of any block is always the topic, that would make your code somewhat equivalent to: sub printRec { my $p; if (defined @_[0]) { $p = shift; } else { $p = @_[0]; } print ":$p:\n"; } Or is the topic of a block mutable (i.e., will a shift cause the topic to shift as well)? If so, I guess your code is actually is equivalent to: sub printRec { my $p = chomp(shift // shift); print ":$p:\n"; } Either way, bizarre, no? What I *think* you meant to say is: sub printRec { my $p = chomp(shift // caller.MY{'$_'}); print ":$p:\n" } which should certainly work, it just makes my skin crawl--vestiges of Perl 4 still coming to bite us, or something. Trey