for my $key (keys %hash){ #... } for my $key (keys %{$hashref}){ # dereferencing a hash #... }