in reply to Dereferencing fetchall_arrayref({})

Y'all are completely wrong. Read the DBI POD before spouting. fetchall_arrayref() does return an array of arrays, but fetchall_arrayref({}) returns an array of hashes.

The reason why the first code works is because the TMPL_LOOP selscene is expecting an array of hashes. When you work with it, $data->[1] is a hashref. So, what you want to do is:

Example A, rewritten: my $data = $sth->fetchall_arrayref({}); if ($data->[0]{title} eq 'large') { ucase( $data->[0]{title} ); } print "First title: '$data->[0]{title}'\n"; $template->param( selscene => $data );

A few comments, in no particular order:

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

Replies are listed 'Best First'.
Re: Re: Dereferencing fetchall_arrayref({})
by bradcathey (Prior) on Apr 25, 2004 at 20:58 UTC
    Thanks dragonchild, ++'s all around. You were right. I tried your rewrite and worked like a charm. Great lesson in dereferencing the AoH. And thanks for the DBI tips--I will try them out. Again, thanks!

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