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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.