Russ has asked for the wisdom of the Perl Monks concerning the following question:
(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...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Putting HTML fieldnames in symbol space
by lhoward (Vicar) on May 27, 2000 at 02:58 UTC | |
by btrott (Parson) on May 27, 2000 at 03:12 UTC | |
by Russ (Deacon) on May 27, 2000 at 03:05 UTC | |
|
Re: Putting HTML fieldnames in symbol space
by btrott (Parson) on May 27, 2000 at 02:52 UTC | |
by Russ (Deacon) on May 27, 2000 at 03:19 UTC | |
|
Re: Putting HTML fieldnames in symbol space
by chromatic (Archbishop) on Jun 06, 2000 at 21:54 UTC | |
|
Re: Putting HTML fieldnames in symbol space
by Jenda (Abbot) on Aug 11, 2006 at 01:14 UTC |