As soon as a s/// matches, the capture buffers are being reset (even if there are no captures in the pattern):
use strict; use warnings; my $string = "p1p2p3"; if ($string =~ m/(p1)(p2)(p3)/) { print "1: $1 $2 $3\n"; my $whatever = "Foo"; $whatever =~ s/foo/bar/; # no match print "2: $1 $2 $3\n"; # $1 etc. of the first match still avail +able $whatever = "foo"; $whatever =~ s/foo/bar/; # match print "3: $1 $2 $3\n"; # "Use of uninitialized value..." }
In reply to Re: modifying en passant
by almut
in thread modifying en passant
by lcschreier
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |