
Cupidvogel
Novice
May 4, 2012, 5:30 AM
Post #1 of 2
(507 views)
|
|
$MATCH not working like $`
|
Can't Post
|
|
Hi, as per the Perlvar manpage, the $PREMATCH variable (alongwith @- and @+ arrays) was meant to do the same thing as $` without the performance overload of the latter. However, when I try the following code:
$a = "abc123dfv"; if ($a =~ m/\d+/) { print "Yep: $PREMATCH \n"; } Nothing gets printed after Yep:, whereas if I run this:
$a = "abc123dfv"; if ($a =~ m/\d+/) { print "Yep: $` \n"; } I get the usual result: Yep: abc. Can anybody explain it?
|