in reply to modifying en passant
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..." }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: modifying en passant
by lcschreier (Novice) on Jan 10, 2010 at 22:41 UTC |