Fellow monasterians,
I'm learning new DBI schemes and have been working with fetchall_arrayref. It works fine as shown, but would like to know how to access the data (see example A), intercepting it, as it were, to manipulate it before committing it to $template -> param(...). The methods are not working and get output like "HASH(0x8301bb8)" and "Not an ARRAY reference." I found thisand this, but not getting any results. Aren't I just deferencing the array? Or is this acting like a hash? Is it even possible? Thanks all!

This works fine (I get populated drop downs in my HTML form):
my $stmt = "SELECT DISTINCT scene, title FROM catalog"; my $sth = my $dbh->prepare($stmt) or die ...r"; $sth->execute() or die ...r" my $data = $sth->fetchall_arrayref({}); my $template -> param ( selscene => $data );
Example A:
my $data = $sth->fetchall_arrayref({}); if ( $data->[1] eq "large" ) { #something like this or... ucase ( $data->[1] ); } print $data->[1],"\n"; #can I even print it $template->param(selscene => $data)
FYI, here's the HTML:
<select name="scenes"> <tmpl_loop name="selscene"> <option value="<tmpl_var scene>"><tmpl_var title></option> </tmpl_loop> </select>

—Brad
"A little yeast leavens the whole dough."

In reply to Dereferencing fetchall_arrayref({}) by bradcathey

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.