for my $key (keys %stack){ for my $value (@{$stack{$key}}){ # do stuff with $key and $value } }