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
In reply to Re: How do you get s/// to look inside variables in the replacement string?
by almut
in thread How do you get s/// to look inside variables in the replacement string?
by markkawika
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |