in reply to
Using Variable Value as Variable Name
Let me strongly echo what I am sure is a pretty-universal sentiment here: don’t expose the variable-name space, even if you find that you can. This creates a program that is not only un-debuggable, but also wantonly open to sabotage. (And, yeah, you have to think about things like “sabotage.”)
If you want to open access to specific variables’ values by name, here is one safe way to do so: create a hash, whose keys are the variable-names, and whose contents for each key is a reference to that variable. This is a controllable and debuggable situation, because “not just any ol’ name you might come up with” can be used; only what exists(). Now, presto!, comes the first obvious simplification: why use a variable-name when you can simply refer to the hash?
Even though we like to say “TMTOWTDI™ == There’s More Than One Way To Do It,” there are definitely ways that are recommend vs. others that are not...