Chady has asked for the wisdom of the Perl Monks concerning the following question:
I just started trying complex structures in Perl, and Bi-Dimensional arrays and hashes.
I was making this form processor, and to be able to allow my co-workers (who have little idea about perl) to add form fields in the program without worrying about updating their use later in the program, so I hacked this piece of code:
In order to use later in the program%fields = ('1.Name' => $cgi->param('name') || 'Anonymous', '2.Email' => $cgi->param('email') || 'No email Supplied', '3.Comments' => $cgi->param('comments') || 'No Comments', '4.Satisfied' => $cgi->param('radio1') || 'Not Specified', );
foreach (sort keys %names) { print "$_ : $names{$_} \n"; }
Why would using the %fields hash in a hash context
Is this always the way with hashes and references?? ( I might not be using the proper namings here ), or maybe it's the way I'm dereferencing the variable later??
Finally the code worked, but I need to get a grip of what happened, cuz I fixed it by mistake
Thanx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Hashes and Refs
by tye (Sage) on Mar 08, 2001 at 02:13 UTC | |
by Chady (Priest) on Mar 08, 2001 at 02:42 UTC | |
|
Re: Hashes and Refs
by arturo (Vicar) on Mar 08, 2001 at 02:06 UTC | |
by Chady (Priest) on Mar 08, 2001 at 02:36 UTC | |
by arturo (Vicar) on Mar 08, 2001 at 02:45 UTC |