Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare %hash to @array

Status
Not open for further replies.

uniopp

Technical User
Oct 7, 2001
152
JP
Could someone please show me how to compare the keys of a %hash to each element of an @array and stop once a match is found then check the next key.
Thank you.
Simon.
 
I think this will do what you want:
Code:
foreach $key (keys %hash) {
   foreach $x (0..$#array) {
      if ( $key eq $array[$x] ) {
         print "Key $key found in array at $x\n";
         last;
      }
   }
}
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top