(Assigning the HTML field name to the symbol table)foreach $key (CGI::param()) { ${$key} = CGI::param($key) }
Now, he can use the HTML field names as variables (e.g. $Username, $Password, etc.) My co-worker defended this idea, saying it is entirely normal (he did it "all the time" in TCL), and that this feels much more readable to him.
So, my question: is this a "normal" thing to do (and I've just never stumbled across the idea) or am I right to have my skin crawl thinking of this?
This just can't be a "good thing," but it's not my code and not my project, so...
<cringing>Russ</cringing>
P.S. I explained the dangers of messing with the symbol table, the risks that someone will name a field (in HTML) to a used/reserved name in Perl, and the loss of maintainability (a variable which just "magically" appears without being referenced anywhere should confuse people). I told him it is considered good practice to run with 'use strict', and that this will not. In the end, I conceded that "yes, the code will work that way..." and our client wrote it, so...
In reply to Putting HTML fieldnames in symbol space by Russ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |