$ 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"
In reply to Re^5: Misreading m// documentation (BUG?)
by Anonymous Monk
in thread Misreading m// documentation
by QM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |