in reply to matching non-word character in perl

my $tag = q{<test-result value="FAIL"/>}; if ($str =~ m/\Q$tag\E/) { print "«$str» contains «$tag»\n"; }

If this is not what you want, please elaborate. Also don't use regexes to match XML, use a module for parsing instead (perhaps XML::LibXML or XML::Twig).