Have a look at eval. Something like this (untested) should work as you desire. I don't think you need the block eval but do not have the ability to test. eval has security implications.
eval{ eval "(\$output = \$string) =~ s/\$regexp/\$new/$suffix" };
In reply to Re: unconventional string substitutions
by tachyon-II
in thread unconventional string substitutions
by halfcountplus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |