in reply to Simple search question ...

Gentle mwhiting

It would help to know more about what you are going to do with this string when you have it. You can leave the + $ ^ characters in place and protect them with \Q:

my $foo = 'a\b*c/d'; my $bar = ' A\B*C/D '; $bar =~ / ^ \s+ \Q $foo \E \s+ $/xi
will evaluate true.

But if you really want to, know that it is 'safe' to backslash all the punctuation characters, so

s/([^\w\s])/\\$1/g
should do what you want. More specifically, backslashing alphanumeric characters makes them 'meta', but only alphanumeric characters become 'meta' when backslashed. So even though you don't need to backslash '#', it will match the same even after it's backslashed.

throop