note
hmerrill
Remember that a hash is a datastructure where each element has a *key* and a *value*. Looking at your code I think your intent was to create a hash (%dataoptions) that had one key "Gender", and that key "Gender" having a related value that is an array whose elements are "Male" and "Female".
<p>So, this:
<code>
my %dataoptions = (
"Gender", ["Male", "Female"]
);
</code>
should be this:
<code>
my %dataoptions = (
"Gender" => ["Male", "Female"]
);
</code>
The other thing to remember is that this:
<code>
["Male", "Female"]
</code>
creates a *reference* to an anonymous array. So in hash %dataoptions, the value corresponding to key "Gender" is a *reference* to an anomyous array containing elements "Male" and "Female". So then when you do
<code>
foreach $option ($dataoptions{$columns[$i]})
</code>
$option is a *reference* to an array.
<p>I think you want your loop to be something like this:
<code>
for ($i = 0; $i < @columns; $i++)
{
print $columns[$i].': ';
my $arrayref = $dataoptions{$columns[$i]};
foreach $option (@$arrayref)
{
print '<input type="radio" name="'.$columns[$i].'" value="'.$option.'"> '.$option.' ';
}
}
</code>
HTH.
403322
403322