in reply to Re: Re: Make a string regexp-safe
in thread Make a string regexp-safe

It is very ugly and it is not very error prone (who knows what changes in regexp syntax can be expected in perl 5.10.0). It is better either to use already mentioned quotemeta or to escape string with \Q and \E in regexp. Example:
my $string = "some unsafe chars"; .... =~ /\Q$string\E/;
It is exactly equivalent to
my $string = "some unsafe chars"; my $temp = quotemeta $string; .... =~ /$temp/;
See perlre for more info.

--
Ilya Martynov (http://martynov.org/)