* Chris Dolan <[EMAIL PROTECTED]> [2006-09-09 03:55]:
> >Works the same. I often use `local $_` in tiny functions that
> >mangle just a single value. Matter of taste/style.
> 
> Ahh, I see -- cargo cult.  ;-)

Err, what? I chose that style for myself. I didn’t pick it up
from anyone else and certainly not unthinkingly.

> I just benchmarked the  two versions, and "my" wins by a wide
> margin:
> 
> % perl test.pl
>           Rate local    my
> local 467290/s    --  -33%
> my    699301/s   50%    --

I dunno if that was supposed to be an argument, but I couldn’t
care less. I hope I don’t have to explain why as well.

* 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).

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Reply via email to