Don't enclose variables in doublequotes!
s/(\${\w+})/find_value_for_var("$1")/e is better written as s/(\${\w+})/find_value_for_var($1)/e! While in this case the quotes cannot "break" the script, it forces Perl to make an additional copy of the matched string each time the regexp matches.
I wish "$var" trigered a warning. While I admit there are valid reasons to do that I bet they make up at most 0.01% of the times it's used. :-(
Jenda
Always code as if the guy who ends up maintaining your code
will be a violent psychopath who knows where you live.
-- Rick Osborne
Edit by castaway: Closed small tag in signature
In reply to Re: Re: replacing "dynamic" variables
by Jenda
in thread replacing "dynamic" variables
by emilford
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |