On Sep 30, Mark Martin said:
I want to compare the elements of an array with the keys in a hash. If
matches are found, I want to store the values associated with the
matched keys in an array for future processing :
my @storage_array = ();
foreach $item(@original array) {
if (exists $original_hash{$item}) {
push(@storage_array, ?????? )
}
}
Your ?????? should just be $original_hash{$item}, I expect, although this
code could be written far more succinctly as a map():
my @storage_array = map {
exists $original_hash{$_} ? $original_hash{$_} : ()
} @original_array;
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://www.perlmonks.org/ % have long ago been overpaid?
http://princeton.pm.org/ % -- Meister Eckhart
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>