http://qs321.pair.com?node_id=525803


in reply to Unrecognized escape \Q passed through in regex

\Q and \E don't work inside interpolations. They only work in regexp literals (m/here/, s/here// and qr/here/). Solutions:

# Text. $text = 'Renata'; $window =~ /\b\Q$text\E\b/ism
and
# Uncompiled regexp. $text = 'Renata'; $regexp = '\\b' . quotemeta($text) . '\\b'; $window =~ /$regexp/ism
and
# Compiled regexp. $regexp = qr/\b\QRenata\E\b/ism; $window =~ $regexp

Note:
The s modifier is useless if you don't use ".".
The m modifier is useless if you don't use "^" or "$".