I'm not sure what's your special situation.
But see this simple test,it can work.
$ perl -e '$hash{x}="33";
$s="xyzx";
for(keys %hash){
$s=~s/\Q$_/$hash{$_}/g
}
print $s '
33yz33
2007/8/27, Petra Vide Ogrin <[EMAIL PROTECTED]>:
> Sorry, tried all that with escaping - doesn't work either
>
> ???
>
> > 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/
> >
> >
> >
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/