# get whole result set into an array my @rs = @{ $sth->fetchall_arrayref() }; # each element of @rs is a reference to a two-member array #let's map the first elements to the keys of the hash # and the second elements to the values. my %hash = map { $_->[0] => $_->[1] } @rs;