That doens't quite explain it. It the first loop, it's as if the implicit local $& is outside of the loop — It prints 'bar' on the 'baz' pass of the loop — while in the second loop, it's as is the implicit local $& is inside of the loop.
Could
print "$&\n" unless /bar/;
suffer from a problem similar to the one from which
my ... if ...;
suffers?
In reply to Re^3: The value of pattern match variable $&
by ikegami
in thread The value of pattern match variable $&
by jesuashok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |