Ilya Zakharevich wrote: > > Inaba Hiroto writes: > > After `next' or `redo', pattern match variables are reset to the block's > > initial value. > > > > $_ = foo; /foo/; > > for (qw/bar baz/) { print "$&\n" unless /bar/; } # print "bar\n" > > for (qw/bar baz/) { next if /bar/; print "$&\n"; } # print "foo\n" > > > > I think it is a bug > > What made you think so? What other block-local things behave like this? I think $& etc. are block local like "{ local $var = $var; ... }". $x = "foo"; for (qw/bar baz/) { local $x=$x; print "$x\n" unless /bar/ and $x="bar"; } for (qw/bar baz/) { local $x=$x; next if /bar/ and $x="bar"; print "$x\n"; } This code print "foo\nfoo\n". If the former code print "foo\nfoo\n", I think it is consistent except the description of $& in "perlvar.pod". $& The string matched by the last successful pattern match (not counting any matches hidden within a BLOCK or eval() enclosed by the current BLOCK). So I think the former code should print "bar\nbar\n" and current behavior is a bug. -- Inaba Hiroto <inaba@st.rim.or.jp>Thread Previous