bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
I'm not even sure I'm using the correct terminology, but here's the scenario. I'm looping through a series of ids to fetch MySQL records into AoH's, each of which must be pushed into a 'final' AoH for use in an HTML::Template loop. I kept getting the error:
Type of arg 1 to push must be array (not private variable) at searchnews.pl line 52, near "@shows)"
My code snippet
my ($stmt, $shows, $allshows); for my $i ( 0 .. $#ids ) { $stmt = "SELECT * FROM shows WHERE id = '$ids[$i]'"; &execute_it( $stmt ); #sub that prepares and executes while ($shows = $sth->fetchall_arrayref({})) { push ($allshows, $shows); } } print Dumper ($allshows);
I understand pushing elements into arrays, but can you push AoHs in to AoHs and how do I keep the reference status for the HTML::Template loop? Is this even possible, or is there a different approach? Thanks all.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pushing AoH refs into another AoH ref
by NetWallah (Canon) on Sep 02, 2004 at 05:33 UTC | |
by bradcathey (Prior) on Sep 02, 2004 at 12:45 UTC | |
|
Re: Pushing AoH refs into another AoH ref
by japhy (Canon) on Sep 02, 2004 at 03:12 UTC |