Re: local vs. my (was Re: code line of the day)
[email protected] (Philippe "BooK" Bruhat) Sat, 9 Sep 2006 22:42:45 +0200
| Newsgroups | gmane.comp.lang.perl.fun |
|---|---|
| Message-ID | <[email protected]> |
Le samedi 09 septembre 2006 à 10:12, A. Pagaltzis écrivait: > > * Uri Guttman <[email protected]> [2006-09-09 05:40]: > > use local only when you MUST use it. mjd has a good article on > > the 7 valid uses of local. just declaring vars in a sub is not > > one of them. > > If you use $_ in any way within a sub, you better localise it or > someone who calls your code is going to be very surprised at some > point (that includes yourself). Why is why you can write « my $_ » in recent Perls, I think. -- Philippe "BooK" Bruhat Honesty is its own reward. Dishonesty is its own punishment. (Moral from Groo The Wanderer #30 (Epic))