in reply to use of DBI perl function fetchall_arrayref
It sounds like others have already pointed you to some good resources for derefencing, etc., but there are two things which are conspicuous in their absence from your code:
- You don't check if the fetchall_arrayref was successful, in terms of displaying $DBI::errstr.
- You don't check if the array reference is really an array reference.
I usually do something like this:
my $ary_ref = $sth->fetchall_arrayref(); if ($DBI::errstr) { print "Error detected: $DBI::errstr\n"; return; } else { if (ref($ary_ref) eq 'ARRAY') { # go on to process the array reference. } else { # do something with Data::Dumper } }
In Section
Seekers of Perl Wisdom