you may need the \Q for meta-character escape.

for (keys %expan) {
    $sbl =~ s/\Q$_/$expan{$_}/g;
}

see also 'perldoc perlre' and search for '\Q'.

2007/8/27, Petra Vide Ogrin <[EMAIL PROTECTED]>:
> Hi all,
>
> I have a hash and some prose text and want my perl to identify the keys of
> the hash in this text and replace them with the corresponding values of
> the keys.
>
> I tried the following
>
> foreach (keys %expan) {
>   if ($sbl =~ m/$_/g) {
>     $sbl =~ s/$_/$expan{$_}/g;
>   }
> }
>
> but it doesn't seem to work properly. What am I doing wrong?
>
> Thanks for the help,
> best,
> Petra
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to