I think the problem is with your $bighash{$day}{$aoa} lookup. Your $aoa is set by a side effect and you are using array ref to be the key ... yuk.

#!/usr/local/bin/perl5 -w use strict; use DBI; use CGI qw/:standard/; my %days; @days{0..6} = qw / Sunday Monday Tuesday Wesnesday Thursday Friday Sat +urday /; my $dbh = DBI->connect('DBI:mysql:tapebot:lid42','','') or die "cannot connect to DB\n" . DBI->errstr; my $sth = $dbh->prepare( qq{ SELECT last,keyno,btype FROM weekly WHERE btype = ? AND day = ? ORDER by keyno }); my $full = "F"; my %bighash = (); foreach my $day (sort keys %days) { $bighash{$day} = get_db_entries($sth, $full, $day); } # your other stuff... my $nrows_max; my $i = "2"; $day = '5'; $i = '0'; print "\nnrows: ${ $bighash{$day}->{nrows} }\n"; print "\nnfields: ${ $bighash{$day}->{nfields} }\n"; print "aoa: ${ $bighash{$day}->{aoa}->[$i]->[2] } after\n"; $dbh->disconnect; sub get_db_entries { my ($sth, $full, $day) = @_; my $nrows = $sth->execute($full, $day) or die "Can't execute statement: " . $dbh->errstr; my %data; $data{aoa} = $sth->fetchall_arrayref(); $data{nrows} = $nrows; $data{nfields} = $sth->{NUM_OF_FIELDS}; return \%data; }

In reply to Re: Passing Array of Array refs as a reference by Roger
in thread Passing Array of Array refs as a reference by tdp05

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.