Do
$a =~ s/(\W)/\\\1/g; # or $a =~ s/(\W)/\\$1/g; [download]
In reply to (tye)Re: Escaping metacharacters by tye in thread Escaping metacharacters by nosduh