in reply to Re^2: Substitution backreference woes
in thread Substitution backreference woes

That's how you go if you want to hold the substitution part in a variable.

my $string = 'Hello sailor'; my $regex = 'Hello (.*)'; my $substitution = '"Goodbye $1"'; $string =~ s/$regex/$substitution/ee; print "string is now <$string> \n";

/usr/bin/perl -w /tmp/regex.pl string is now <Goodbye sailor>

Cheers Rolf

PS: Je suis Charlie!

Replies are listed 'Best First'.
Re^4: Substitution backreference woes
by Anonymous Monk on Jan 24, 2015 at 13:59 UTC

    Yes, that seems to work perfectly. Thank you.