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 } }
In reply to Re: using shift and $_ in loop
by ikegami
in thread using shift and $_ in loop
by leocharre
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |