foreach (qw/foo bar/) {
print;
print foreach (qw/one two three/);
}
# output: fooonetwothreebaronetwothree
####
foreach (qw/foo bar/) {
print;
my @list = qw/one two three/;
print while (shift @list);
}
# output: foofoofoofoobarbarbarbar
##
##
foreach (qw/foo bar/) {
print;
my @list = qw/one two three/;
print while (local $_ = shift @list);
}
# output: fooonetwothreebaronetwothree
##
##
{ local $_; print while (shift @list); }
##
##
# will not localize $_ to the while loop
local $_; print while (shift @list);