First, this /ee stuff is messy and I read this post StackOverflow re: variable in replacement side which talks about some of the details.
Then I came across: String::Substitution module.
I figured that this module does exactly what you want, so I installed and tested it.
You can read thru the docs and see more options.use strict; use warnings; use String::Substitution qw(gsub_copy); my $in_string = 'foo.ra'; my $find_exp = '\.(.)(.)$'; my $replace_exp = 'b$2$1s'; my $output = gsub_copy($in_string, $find_exp, $replace_exp); print "$output\n"; # prints: foobars
In reply to Re: sprintf using variables for format and variables to do a search and replace, sprintf issues
by Marshall
in thread sprintf using variables for format and variables to do a search and replace, sprintf issues
by kevins4perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |