regex - Perl search and replace with variable and capture group -


as question says, trying search replace using variable , capture group. is, replace string contains $1. followed answers here , here, did not working me; $1 comes through in replace. can me spot problem?

i reading regular expressions file so:

while( $line = <$file>) {     @findrep = split(/:/, $line);     $find = $findrep[0];     $replace = '"$findrep[2]"'; # contains $1     $alltxt =~ s/$find/$replace/ee; } 

if manually set my $replace = '"$1 stuff"' replace works expected. have played around every single/double quoting , /e combination can think of.

you're using single quotes $findrep[2] isn't interpolated. try instead:

my $replace = qq{"$findrep[2]"}; 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -