in reply to Scalar assignment with loop iterator considered bad?
Because there is no block, $foo is in scope for the print. But for reasons I can't really explain, it's not handled as you might expect, and $foo is undefined in the print. If you declare $foo separately prior to the for, then it works as expected.my $foo .= ",$_" for qw(1 2 3); print "$foo\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Scalar assignment with loop iterator considered bad?
by wazoox (Prior) on Jul 23, 2005 at 14:16 UTC | |
by Roy Johnson (Monsignor) on Jul 25, 2005 at 16:06 UTC |