If you have variable names containing something other than just \w, you'll have to expand the regex a bit, but there's the mechanism you need. ${'varnam'} is the same as $varname.my $aha = 'upon'; my $oho = 'a'; my $text = 'once $aha $oho time'; $text =~ s/\$(\w+)/${$1}/g; print $text;
In reply to Re: Interpolating variables in a string
by TedPride
in thread Interpolating variables in a string
by saintmike
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |