You don't want to do that. Look up "symbolic references" or "soft references" for more information as to why. For one thing, they won't do variables that have been declared with
my, as you would usually do under strictures.
Much better is to have a hash that contains all the variable names you wish your file to be allowed to used. Then, you would do s/\$(\w+)/$hash{$1}/g;
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?