Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Builtin functions defaulting to $_by ikegami (Patriarch) |
on Mar 23, 2007 at 15:51 UTC ( [id://606271]=note: print w/replies, xml ) | Need Help?? |
How to make your own function that defaults to $_:
The for is a convenient way to alias $_. (local $_ is buggy. It doesn't work well if $_ is tied or aliased to someting that's tied, and it doesn't protect pos($_).) Of course, you could just work with $arg directly instead of aliasing $_ to it. The use of a lexical ($arg) allows us to modify $_ without affecting the argument in the caller. If you don't modify $_, the above can be simplified to
In Section
Meditations
|
|