M
Mark Fletcher
I have tried everything I can think of and cannot solve this. Any help appreciated.
#!/usr/bin/perl -w
use strict;
my ($s, $pat, $rpl);
$s = "ABCDEF abc000 RSTUV";
$pat = '(.*abc)...(.*)';
$rpl = '${1}777${2}';
# Works...
$_ = $s;
s/(.*abc)...(.*)/${1}777${2}/;
print "$_\n";
# Does not work...
$_ = $s;
s/$pat/$rpl/;
print "$_\n";
OUTPUT:
ABCDEF abc777 RSTUV
${1}777${2}
#!/usr/bin/perl -w
use strict;
my ($s, $pat, $rpl);
$s = "ABCDEF abc000 RSTUV";
$pat = '(.*abc)...(.*)';
$rpl = '${1}777${2}';
# Works...
$_ = $s;
s/(.*abc)...(.*)/${1}777${2}/;
print "$_\n";
# Does not work...
$_ = $s;
s/$pat/$rpl/;
print "$_\n";
OUTPUT:
ABCDEF abc777 RSTUV
${1}777${2}