[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
[MacPerl] Regex replace problem
I'm new at Perl (and this list) and I couldn't find out how to do this in
the book.
I have a hash table where the keys are search patterns and the values are
the replace string, e.g.:
$my_hash{"{(.*?)}"}= '$1';
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.
Help please!
/Peder
Peder Axensten
mailto:f95-pax@nada.kth.se (Umea, Sweden)
===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org