use strict; my %hash = ('a'=>'hello', 'b'=>'goodbye', 'c'=>'foobar'); foreach my $key(keys %hash){ # iterates over 'a', 'b' and 'c' print "the value of $key is $hash{$key}\n"; }