in reply to using shift and $_ in loop
that assigns to $_ issub scribble { while ( $a = shift ){ $a; # has arg } }
sub scribble { while ( $_ = shift ){ $_; # has arg } }
In both cases, you are using global variables. $_ is particularly dangerous to clobber. Fix:
sub scribble { local $_; while ( $_ = shift ){ $_; # has arg } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using shift and $_ in loop
by leocharre (Priest) on Oct 21, 2009 at 15:59 UTC | |
by ikegami (Patriarch) on Oct 21, 2009 at 16:37 UTC | |
by leocharre (Priest) on Oct 21, 2009 at 20:26 UTC | |
by ikegami (Patriarch) on Oct 21, 2009 at 20:34 UTC |