Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
If I need a temporary variable, I don't have a problem with declaring my $foo (but usually call it something a little more meaningful). Actually, I tend to declare most variables with my anyway, unless for some reason their scope really is global.
It makes the code more modular and less likely to have unintended side effects, like modifying the global $_ that you mention.
I'd recommend just biting the bullet and typing "local" if you must use $_ as a temporary variable. That's what local is for, after all. :-) -- Mike -- In reply to Re: Using $_ as a temp var, especially in functions
by thelenm
|
|