faqts : Computers : Programming : Languages : Perl : Common Problems : Hashes

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

33 of 38 people (87%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do I loop through a hash?

Jun 16th, 2001 10:58
Per M Knutsen,


Use foreach. Example:
foreach $key (sort keys %hash) {
   print "key: $key  value: $hash{$key}\n";
}