$ perl -Mre=debug -e " $x = q{\d}; $f = 1234; $f =~ q{$x} " Compiling REx "$x" Final program: 1: EOL (2) 2: EXACT (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 (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"