|
|
| Syntactic Confectionery Delight | |
| PerlMonks |
Re: Problems with map(function, array)by tobyink (Prior) |
| on Dec 10, 2012 at 22:41 UTC ( #1008177=note: print w/ replies, xml ) | Need Help?? |
|
Nothing to do with map really. uc has magic! In the following construct, uc is getting called with no parameters:
As per perlfunc, when called with no parameters, uc operates on $_. So you need to make your function act the same (as indeed you did in your second experiment). From Perl 5.10 and above, there's a better technique to write such functions:
And now my_uc has the same magic as uc.
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||