... my $SELECT = qq/select field1, value1 , field2, value2 from table/; my $sth = $dbh->prepare($SELECT); $sth->execute; while( my $row = $sth->fetchrow_arrayref ) { my %hash = @$row; ..... }