in reply to Re^2: Interpolate into replacement with s//?
in thread Interpolate into replacement with s//?
$replace contains a template. Therefore, you need a template engine to process it.Aw /gee whiz, we don’t need no stinkin’ modules for such a trivial task. Merely render unto Perl that which is Perl’s:
Which when run duly prints out ZaZBC.use v5.14; my $string = q/ABC/; my $search = qr/^(A)/; my $replace = q/"Z\l$1Z"/; $string =~ s/$search/$replace/gee; say $string;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Interpolate into replacement with s//?
by philkime (Beadle) on Nov 09, 2011 at 21:18 UTC | |
by ikegami (Patriarch) on Nov 09, 2011 at 21:31 UTC | |
by philkime (Beadle) on Nov 10, 2011 at 09:14 UTC | |
by ikegami (Patriarch) on Nov 14, 2011 at 19:15 UTC | |
by philkime (Beadle) on Nov 23, 2011 at 13:29 UTC | |
|