for my $i (0 .. $#all_ids) { my $key = $all_ids[$i]; if(exists $hash{$key}) { print "$key => $hash{$key} => $all_gc3s[$i]\n"; } else { print "Item '$key' is not in the hash.\n"; } }