Mark Healey <> wrote:
> On Sat, 24 Jun 2006 06:32:29 +0000, Jürgen Exner wrote:
>
>> Mark Healey wrote:
>>> Here is the line that is giving me problems:
>>>
>>> $Falbum =~ s/$edir\/.\/$Fartist\///;
>>>
>>> The problem is that $Fartist sometimes has grouping characters "()[]"
>>> which screws up the search.
>>>
>>> How do I get it to treat these characters as if they were "\(\)\[\]"?
>>
>> perldoc -f quotemeta
>
> This doesn't help when I'm using some meta characters in my search
> strings.
Yes it does.
> I need something that only does it to the variables.
quotemeta only does it where you ask it to do it, so ask it to
do it "to the variables":
$edir = quotemeta $edir;
$Fartist = quotemeta $Fartist;
$Falbum =~ s#$edir/./$Fartist/##; # Look Ma! No backslashes!
or, lookup the \Q that the docs mention:
$Falbum =~ s#\Q$edir\E/./\Q$Fartist/##;
--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas