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 available $whatever = "foo"; $whatever =~ s/foo/bar/; # match print "3: $1 $2 $3\n"; # "Use of uninitialized value..." }