![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
You've put your chaining at a disadvantage in the ugliness department by illustrating it with mutators of $_. This technique shines in combination with other list operators like grep and sort, and when wrapped in a subroutine so that it acts on a copy of @_.
The real alternative is nested sub calls. While those look messy in C, with all the parens to be balanced, they have an equally nice expression in Perl, my $quux = foo bar baz $_; One of the better reasons to use map in this way is the aliasing of localized $_ to each argument in turn. That is not a big advantage in your actions on a list of one element, but is a nice shorthand when operations act on $_ by default. You missed an opportunity to use that in the map { uc } stage. Of course, this is all extremely powerful when acting on lists. The Schwartzian Transform is on anybody's list of "Best Dressed Perl". After Compline, In reply to Re: Confessions of a back-alley map abuser
by Zaxo
|
|