use strict; use warnings; my $teststring = qq/Hello# World/; my $regex1 = qr{\QHello# World\E}x; my $regex2 = qr{Hello\#\ World}x; my $regex3 = qr{$teststring}x; my $regex4 = qr{\Q$teststring\E}x; print "String is $teststring\n"; print "Regex1 is $regex1\n"; print "Regex2 is $regex2\n"; print "Regex3 is $regex3\n"; print "Regex4 is $regex4\n";