my $sth = $dbh->prepare("select * from finalLevel3 where id=?"); foreach $item (@{$clusters}) { $ID = $units[$i][0]; unless (eval { @row = $dbh->selectrow_array($sth, undef, $ID); 1 }) { die "Error on ID [$ID]: $@"; } # convert the mysql result back to a string again $promoter_line = join "\t", @row; $promoter_line .= "\n"; $parser_hash{$item} .= $promoter_line; $i++; }