[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [MacPerl] Regex replace problem
On Fri, Jun 04, 1999 at 03:48:30PM +0200, Peder Axensten wrote:
> Futher down I use this in:
> while (($find, $replace)= each (%my_hash)) {
> $whatever=~ s/$find/$replace/g;
> }
>
> The $find part works great, but $replace is problematic. It results in
> either the string '$1' literally or the value of $1 when it was put into
> the hash, not when the regex was executed.
>
> I've tried ='$1', ="$1", ="\$1" etc. and with the 'evaluate' flag with the
> regex but I can't get it to work.
>
You can't get delayed evaluation by messing with the assignment of the
replace string. You have to get it from the substitution.
s/$find/$replace/gee;
The first /e evaluates '$replace' to '$1'. The second /e evaluates '$1' to
the value of $1.
Ronald
===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org