in reply to Re: Substitution backreference woes
in thread Substitution backreference woes
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Substitution backreference woes
by LanX (Saint) on Jan 24, 2015 at 13:17 UTC | |
|
Re^3: Substitution backreference woes
by LanX (Saint) on Jan 24, 2015 at 13:27 UTC | |
by Anonymous Monk on Jan 24, 2015 at 13:59 UTC |