you have to change the
foreach in your inner loop for a
while (right now it is only iterating once over the hash), or change the
foreach inner loop to use
keys %hash instead of
each %hash (so it iterates over every key). Also, you are using
== to compare the elements in the array to the keys in the hash, so this will only work for numeric values. You could try something like this instead:
foreach my $thing (@array) {
if ( exists $hash {$thing} ) {
push @new_array, $hash {$thing};
}
}
hope this helps,