kosta:

It used the first line because that's what you gave it. The arrayref returned from (presumably DBI) is an arrayref with each row being an arrayref containing one row of the data. So you need to create an arrayref with one row containing all your data items. One way to do it would be to make a hash slice in your fetchall_arrayref call, then you can pass either the keys or values list to popupmenu.

Alternatively, you can build a new arrayref that holds only the values in the first column, something like this:

my @tmp=map { $_->[0] } @$res;

which is roughly the same as:

my @tmp=(); push @tmp, $_->[0] for @$res;

The first one, though can be used in a single line with the popupmenu call:

popupmenu(-values=>[ map { $_->[0] } @$res ]);

Note: I didn't test any of this, so you'll have to fix any syntax errors I made.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: using fetchall_arrayref in popupmenu by roboticus
in thread using fetchall_arrayref in popupmenu by kosta

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.