Hi John, I am not only expanding a variable but also using that expanded variable as a key to ultimately find the value. That's why I need "e".
Secondly, inside text that is to be substituted, I can use \1 as well. And moreover, for this, I don't need double quotes. If i purposefully incorporate double quotes, then I need $1. Regards, Amit Saxena On Tue, Jul 1, 2008 at 4:19 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: > Amit Saxena wrote: > >> Why don't use perl "s" operator with "e" option ? >> >> $str =~ s/([^ ]+)/$hash{\1}/ge >> > > You don't need the /e option to interpolate a variable in a double quoted > string and you should use $1 instead of \1 inside a double quoted string: > > $str =~ s/([^ ]+)/$hash{$1}/g > > > John > -- > Perl isn't a toolbox, but a small machine shop where you > can special-order certain sorts of tools at low cost and > in short order. -- Larry Wall > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > >