use re 'debug'; $x = "\\B"; $y = "Here is \\B"; print $y =~ /$x/ ? "y" : "n"; __END__ Compiling REx `\B' size 2 Got 20 bytes for offset annotations. first at 1 1: NBOUND(2) 2: END(0) stclass "NBOUND" minlen 0 Offsets: [2] 1[2] 3[0] Matching REx "\B" against "Here is \B" Matching stclass "NBOUND" against "Here is \B" Setting an EVAL scope, savestack=3 1 | 1: NBOUND 1 | 2: END Match successful! yFreeing REx: `"\\B"'