Comparing an array with hash keys



Hi,
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, ?????? )
			}
}

Cheers,
Mark

.



Relevant Pages

  • Re: hash tables, non-random keys
    ... I have a hash table that will be containing a non-uniform distribution ... The keys will be inserted sequentially, ... would just use an array. ... something I also sometimes do is to use a small hash to optimize lookups ...
    (comp.programming)
  • Re: HOA redundancy in array.
    ... creates a new hash called $saw. ... corresponding to the given keys. ... [Given that @HOH_protein is an array, therefore $pro_name is a number, ... for my $got (@uniqs) { ...
    (comp.lang.perl.misc)
  • Re: populating a hash with % used as the key and F string as the value
    ... > keys %lookup; ... it states one cannot push or pop a hash on page 10 ... itself is the reference to the array (read: an arrayref). ...
    (perl.beginners)
  • Re: maintaining order in a hash (without Tie::IxHash)
    ... Save the keys in a separate array and iterate over the array. ... >> is the simplest approach at the expense of duplicate storage of the ... accessing a large hash by sorting a ...
    (comp.lang.perl.misc)
  • Re: Traversing a hash with array refs as keys?
    ... Hash keys can only be strings. ... So is your key an array or an array reference? ... As mentioned above keys must be strings. ...
    (comp.lang.perl.misc)