in reply to cgi.pm: popup_menu

keys %labels should do the trick.

Replies are listed 'Best First'.
Re: Re: cgi.pm: popup_menu
by arturo (Vicar) on Mar 14, 2003 at 21:31 UTC

    the -labels attribute expects an array reference, not a list, so that should instead be -labels => [ keys %labels ]

    the [ ] around the keys %labels makes it an anonymous array, which is a reference to an array with no name.

    HTH

    If not P, what? Q maybe?
    "Sidney Morgenbesser"

Re: Re: cgi.pm: popup_menu
by slackah (Initiate) on Mar 15, 2003 at 03:03 UTC
    its not working though, and when i do this

    my @temp = keys %labels;
    my $temp2;
    foreach(@temp) {
    $temp2.="'$_'";
    $temp2.=",";
    }
    chop $temp2;

    print $q->popup_menu(-name=>'menu_name', -values=>$temp2, -default => $q->param('product'), -labels=>%labels);

    It just prints $temp2 as one value.