in reply to How do you get s/// to look inside variables in the replacement string?

One way would be to use double eval:

#!/usr/bin/perl my $str = 'abc'; my $match = '(a)(.)'; my $repl = '$2$1'; $str =~ s/$match/"\"$repl\""/ee; print "$str\n"; # bac
  • Comment on Re: How do you get s/// to look inside variables in the replacement string?
  • Download Code

Replies are listed 'Best First'.
Re^2: How do you get s/// to look inside variables in the replacement string?
by markkawika (Monk) on Nov 28, 2007 at 01:40 UTC
    Thanks, that does exactly what I need.