in reply to Re^2: Substitution backreference woes
in thread Substitution backreference woes
my $string = 'Hello sailor'; my $regex = 'Hello (.*)'; # my $substitution = 'Goodbye \1'; $string =~ s/$regex/Goodbye $1/; print "string is now <$string> \n";
/usr/bin/perl -w /tmp/regex.pl string is now <Goodbye sailor>
Please note that \1 is somehow deprecated in the substitution part and will cause warnings.
Its only legitimate use is in the match part for backreference.
|
|---|