I'd like to report a bug in CGI.pm-3.41 that occurs when using
popup_menu to create a popup menu.
Perl version: "This is perl, v5.8.8 built for i686-linux"
OS vender and version: Linux hostname.com 2.6.9-55.0.12.ELsmp #1 SMP
Fri Nov 2 11:19:08 EDT 2007 i686 i686 i386 GNU/Linux
Consider the code:
use CGI;
my $q = new CGI;
print $q->popup_menu(
-name => 'active',
-value => [ 1, 0 ],
-default => 0,
-labels => { '1' => 'Yes', '0' => 'No' }
)
I would expect this to create a popup menu with two options, "Yes"
and "No," and that "No" would be the default selected value. What
happens is that the menu is created, but the default value is not
selected, and since "No" is the second value, the "Yes" shows up as
the default value.
When you wrap the 0 in an array ref, which the documentation says is
for providing multiple values, the 0 value works. The following code
produces the menu as expected:
use CGI;
my $q = new CGI;
print $q->popup_menu(
-name => 'active',
-value => [ 1, 0 ],
-default => [ 0 ],
-labels => { '1' => 'Yes', '0' => 'No' }
)
Thanks,
Patrick Cronin