my %hash = qw(foo bar baz qux one two three four); my @key = keys %hash; my @val = values %hash; print "$key[$_] => $val[$_]\n" for 0..$#key;