my $join = 'customer_id'; my $sth = $global{DBH}->prepare(" select * from voice_calls "); my $cth = $global{DBH}->prepare(" select * from customers where $join=?"); $sth->execute(); while ( my $call = $sth->fetchrow_hashref() ) { $cth->execute( ${$call}{$join} ); my $customer = $cth->fetchrow_hashref(); $cth->finish; foreach my $key (keys %$customer) { ${$call}{$key} = ${$customer}{$key} } # end-foreach push(@{$self->{RESULTS}}, \%{$call}); } # end-while $sth->finish;