in reply to Re^2: Using a regex capture as part of a varible
in thread Using a regex capture as part of a varible
You need to set up your replacement string correctly. Once that's done it runs fine with the /ee modifier:
use strict; use warnings; use Test::More tests => 1; my $new = 'blah'; my $string = 'asdfjkjl'; my $find = '(asd)'; my $replace = qq#\${1} . '$new'#; my $result = replace ($string, $find, $replace); is $result, 'asdblahfjkjl'; sub replace { my $string = shift; my $left = shift; my $replace = shift; $string =~ s/$left/$replace/ee; return $string; }
|
|---|