That seems to produce the same result, namely:
string is now Goodbye \1
#!/usr/bin/perl use strict; use diagnostics; use warnings; my $string = 'Hello sailor'; my $regex = 'Hello (.*)'; my $substitution = 'Goodbye \\1'; $string =~ s/$regex/$substitution/; print "string is now $string \n"; # I wanted: string is now Goodbye sailor # I got: string is now Goodbye \1
In reply to Re^2: Substitution backreference woes
by Anonymous Monk
in thread Substitution backreference woes
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |