I am working with CGI.pm, and am having difficulties getting things to work, it may be a basic perl issue, or it may be something specific to CGI.pm. Here's what I am doing.
I want to use popup_menu to generate an HTML select. I can get this code to work just fine:
print $CGI->popup_menu(-name=>'menu_name', -values=>{'one'=>'eenie', 'two'=>'meenie', 'three'=>'minie'});
(where $CGI was created earlier with $CGI = new CGI;)
This works fine, so now I want to make the hash literal a has variable, so I try this:
%menu_values = {'eenie'=>'one', 'meenie'=>'two', 'minie'=>'three'}; print $CGI->popup_menu(-name=>'menu_name', -values=>%menu_values);
But what gets generated is this:
<select name="menu_name" > <option value="HASH(0x40132724)">HASH(0x40132724)</option> </select>
Huh? So I turn to my perl book "Learning Perl" published by O'Reilly, and see that it has hash literals in parens. Curious, but I try that, change my {} to (). But, now this is generated:
<select name="menu_name" three="meenie" one="minie" two> <option value="eenie">eenie</option> </select>
and I'm surprised that my browser even accepts it, but its not right. Please, what am I doing wrong?
Edit: g0n - code tags
In reply to popup_menu CGI.pm problems by kmullin5016
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |