in reply to Re^2: cpan install($_) doesn't work in loop, but normal lexical var does
in thread cpan install($_) doesn't work in loop, but normal lexical var does
"...is there any compelling reason not to do a "local $_;" at the beginning of every subroutine?"
Yes, doesn't fix the problem. Any time you call a function, subroutine or method it could blow away $_. And you will never have control of other peoples code so if you rely on $_ not being hosed you'll eventually get burnt. Far better is to practice defensive programing and not rely on $_ after all the perl syntax in all cases allows you to specify something other that the default input/output scalar.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: cpan install($_) doesn't work in loop, but normal lexical var does
by doom (Deacon) on Aug 28, 2006 at 02:29 UTC | |
by starbolin (Hermit) on Aug 29, 2006 at 00:47 UTC | |
by shmem (Chancellor) on Aug 29, 2006 at 06:45 UTC |