my $result_rows = $sth->fetchall_arrayref; if ( ref( $result_rows ne 'ARRAY' or @$result_rows == 0 ) { print "Oops! No data. Now what?\n"; } else { print "Yo! you got " . scalar( @$result_rows ) . " records:\n"; for my $row ( @$result_rows ) { print join( "\t", @$row ), "\n"; } }