in reply to DBI and fetchall_arrayref

Try checking how many rows are returned first:
if ( scalar @$result > 0) { ... process rows ... print $result[0]->{'b'}."\n"; } else { ... no rows returned logic ... }

Replies are listed 'Best First'.
Re^2: DBI and fetchall_arrayref
by mje (Curate) on Feb 20, 2009 at 13:24 UTC
Re^2: DBI and fetchall_arrayref
by jethro (Monsignor) on Feb 19, 2009 at 17:57 UTC

    Small correction:

    print $result->[0]->{'b'}."\n";
      Small correction

      Actually, $result->[0]{b} will work just fine as well. You don't need to dereference explicitly after the first one, nor do bareword keys need to be quoted.

      Concision, concision!

      • another intruder with the mooring in the heart of the Perl

      you don't even need arrows or periods :)
      #!/usr/bin/perl -- use strict; use warnings; my $result = [ { b => 'small erection' } ]; print $result->[0]->{'b'}."\n"; print $result->[0]{b}."\n"; print "$$result[0]{b}\n"; print "$result->[0]{b}\n"; __END__ small erection small erection small erection small erection
        See perldoc DBI