CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
$MATCH not working like $`

 



Cupidvogel
Novice

May 4, 2012, 5:30 AM

Post #1 of 2 (672 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:


Code
$a = "abc123dfv"; 
if ($a =~ m/\d+/) {
print "Yep: $PREMATCH \n";
}


Nothing gets printed after Yep:, whereas if I run this:


Code
$a = "abc123dfv"; 
if ($a =~ m/\d+/) {
print "Yep: $` \n";
}


I get the usual result: Yep: abc. Can anybody explain it?


FishMonger
Veteran / Moderator

May 4, 2012, 6:15 AM

Post #2 of 2 (654 views)
Re: [Cupidvogel] $MATCH not working like $` [In reply to] Can't Post

You question was answered on devshed.
http://forums.devshed.com/perl-programming-6/match-not-working-like-903193.html

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives