Problems? Is your data what you think it is? | |
PerlMonks |
Re: Using $_ as a temp var, especially in functionsby thelenm (Vicar) |
on Oct 23, 2002 at 03:00 UTC ( [id://207270]=note: 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 Section
Meditations
|
|