use re 'debug'; $x = "A\\B"; $y = "Here is A\\B"; print $y =~ /$x/ ? "y" : "n"; __END__ Compiling REx `A\B' size 4 Got 36 bytes for offset annotations. first at 1 1: EXACT (3) 3: NBOUND(4) 4: END(0) anchored "A" at 0 (checking anchored) minlen 1 Offsets: [4] 1[1] 0[0] 2[2] 4[0] Guessing start of match, REx "A\B" against "Here is A\B"... Found anchored substr "A" at offset 8... Starting position does not contradict /^/m... Guessed: match at offset 8 Matching REx "A\B" against "A\B" Setting an EVAL scope, savestack=3 8 | 1: EXACT 9 <\B> | 3: NBOUND failed... Match failed nFreeing REx: `"A\\B"'