Laila has asked for the wisdom of the Perl Monks concerning the following question:
Let's say you had to print a whole bunch of radio buttons while inside a loop, and that you then wanted to call them using the param function.
The param function would look like this:
if (! param ) { show_form(); } elsif (defined param ('file_chosen)) { parse_text(); } elsif (defined param('$temp_name')) {print print_results(); }
and somewhere down the file, you have something like:
while ($counter<=$#doc_offset_array) { @temp_array = @{$array_of_arrays[$counter] }; $temp_name =$doc_offset_array[$counter]; foreach $i (@temp_array) { print radio_group(-name=>'$temp_name', -values=>[@temp_array], -linebreak=>'true'); } } }
My problem is that I can't get param to handle a scalar as an argument.
If I use single quotes in both sets of code, the elsif statement executes, but the radio buttons are all in one group rather than separate groups.If I just use $temp_name (without quotes) in the radio_group, and single quotes around it in the param function, the radio buttons are fine, but the elsif statement doesn't execute.
Any suggestions?
Thanks
2001-03-28 Edit by Corion : Added CODE tags and tried to fix the indentation
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Param and Scalars
by Masem (Monsignor) on Mar 28, 2001 at 07:36 UTC | |
by Laila (Initiate) on Mar 28, 2001 at 08:19 UTC | |
by kal (Hermit) on Mar 28, 2001 at 15:52 UTC |