in reply to backreferencing fails in a search and replace with a hash

You need String::Interpolate (or something similar) and the /e modifier:
use String::Interpolate qw(safe_interpolate); ... $line =~ s/$key/safe_interpolate($fsr_hash{$key})/e;

(Untested). If you are sure that there are no "evil" components in the replace string you can use eval to do the work of String::Interpolate.

Replies are listed 'Best First'.
Re^2: backreferencing fails in a search and replace with a hash
by tonyz (Novice) on Aug 02, 2008 at 14:40 UTC
    moritz, I've just tested your suggestion, and it works. Thank you very much! (And thanks to the other Monks also for pointing me in the right direction!)