sub read_from_db { my %params = @_; my $dbh = $params{-dbh} || ""; my $query = $params{-query} || ""; my @results_array; if ($dbh =~ /DBI/) { my $sth = $dbh->prepare($query); my $result = $sth->execute(); while (my $row = $sth->fetchrow_hashref()) { tie my(%hash_to_return), "Tie::IxHash"; map({$hash_to_return{$_}=$row->{$_}} @{$sth->{NAME}}); my $ref = \%hash_to_return; push(@results_array, $ref); } $sth->finish; } return @results_array; }