Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: Misreading m// documentation (BUG?)

by Anonymous Monk
on Mar 12, 2014 at 12:07 UTC ( [id://1078012]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Misreading m// documentation (BUG?)
in thread Misreading m// documentation

Yes, interpolation means double quoted string, regex metacharacters are still regex metacharacters m/.$/ and m'.$' match the same string
$ perl -Mre=debug -e " $_ = 1234; m/.$/ " Compiling REx ".$" Final program: 1: REG_ANY (2) 2: EOL (3) 3: END (0) anchored ""$ at 1 minlen 1 Matching REx ".$" against "1234" 3 <123> <4> | 1:REG_ANY(2) 4 <1234> <> | 2:EOL(3) 4 <1234> <> | 3:END(0) Match successful! Freeing REx: ".$" $ perl -Mre=debug -e " $_ = 1234; m'.$' " Compiling REx ".$" Final program: 1: REG_ANY (2) 2: EOL (3) 3: END (0) anchored ""$ at 1 minlen 1 Matching REx ".$" against "1234" 3 <123> <4> | 1:REG_ANY(2) 4 <1234> <> | 2:EOL(3) 4 <1234> <> | 3:END(0) Match successful! Freeing REx: ".$"

variables interpolate in double quoted strings but metachars are still metachars

$ perl -Mre=debug -e " $x = q{\d}; $f = 1234; $f =~ q{$x} " Compiling REx "$x" Final program: 1: EOL (2) 2: EXACT <x> (4) 4: END (0) anchored "x" at 0 (checking anchored) minlen 1 Guessing start of match in sv for REx "$x" against "1234" Did not find anchored substr "x"... Match rejected by optimizer Freeing REx: "$x" $ perl -Mre=debug -e " $x = q{\d}; $f = 1234; $f =~ qq{$x} " Compiling REx "\d" Final program: 1: DIGIT (2) 2: END (0) stclass DIGIT minlen 1 Matching REx "\d" against "1234" Matching stclass DIGIT against "1234" (4 bytes) 0 <> <1234> | 1:DIGIT(2) 1 <1> <234> | 2:END(0) Match successful! Freeing REx: "\d" $ perl -Mre=debug -e " $x = q{\d}; $f = 1234; $f =~ qq{\$x} " Compiling REx "$x" Final program: 1: EOL (2) 2: EXACT <x> (4) 4: END (0) anchored "x" at 0 (checking anchored) minlen 1 Guessing start of match in sv for REx "$x" against "1234" Did not find anchored substr "x"... Match rejected by optimizer Freeing REx: "$x" $ perl -Mre=debug -e " $x = q{\d}; $f = 1234; $f =~ q{\$x} " Compiling REx "\$x" Final program: 1: EXACT <$x> (3) 3: END (0) anchored "$x" at 0 (checking anchored isall) minlen 2 Guessing start of match in sv for REx "\$x" against "1234" Did not find anchored substr "$x"... Match rejected by optimizer Freeing REx: "\$x"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1078012]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-24 04:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found