my @keys=qw(e1 e2 e3 e4); ... my $result_href = $sth->fetchrow_hashref ... my @values = @{$result_href}{@keys};