in reply to HTML as radio_group label w/CGI.pm
Your code could definitely benefit from use strict; and use warnings; — you're declaring a hash (and also creating it at the same time), and then you try and treat it like an array when CGI.pm actually expects a hash reference (you can do magic to make something like this work, but you don't want to).
Something like this does what you mean:
Here I'm creating a hash (the my %labels lines). Pass the list of possible values for the group (monkey; cat; dog) as an array reference created by the [] operator (keys merely returns the keys of a hash as a list). Then provide the labels for each of the values by passing a hashref.use warnings; use strict; use CGI qw(:standard); use Data::Dumper; my %labels = ( monkey => "sigmund", cat => "felix", dog => "fido", ); print radio_group(-name=>'clearchannel', -values=>[keys %labels], -labels=>\%labels);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HTML as radio_group label w/CGI.pm
by Anonymous Monk on Sep 25, 2005 at 15:54 UTC |