# assuming CGI.pm loaded # this function covers only the named parameter style # with '-name' names sub checkbox_group { my %opt = @_; $opt{-values} ||= []; $opt{-labels} ||= { map{($_,$_)} @{$opt{-values}} }; defined $opt{-default} or $opt{default} = ''; $opt{-name} or return; my $i=time; return map { my $id = $opt{-name}.$i++; CGI::checkbox( -name => $opt{-name}, -id => $id, -value => $_, -label => '',#disbale CGI.pm labeling ($opt{-default} eq $_ ? (-checked=>1) : () ) ), qq## #our "real" labeling } @{$opt{-values}}; } print checkbox_group( -name => 'foo', -values => [qw/a b c/], -labels => {a=>'A',b=>'B',c=>'C'}, -default => 'a', );