Question: I have Hash where values of keys are other Hashes.

Example: `{'key' => {'key2' => {'key3' => 'value'}}}`

How can I iterate through this structure?

Answer: 
Is this what you want? (untested)

```
sub for_hash {
    my ($hash, $fn) = @_;
    while (my ($key, $value) = each %$hash) {
        if ('HASH' eq ref $value) {
            for_hash $value, $fn;
        }
        else {
            $fn->($value);
        }
    }
}

my $example = {'key' => {'key2' => {'key3' => 'value'}}};
for_hash $example, sub {
    my ($value) = @_;
    # Do something with $value...
};

```
If you are using perl as a "CPAN interpreter" then in addition to [`Data::Visitor`](https://metacpan.org/pod/Data::Visitor) and [`Data::Deep`](https://metacpan.org/pod/Data::Deep) there is the super simple [`Data::Traverse`](https://metacpan.org/pod/Data::Traverse):

```
use Data::Traverse qw(traverse);

my %test_hash = (
  q => [qw/1 2 3 4/],
  w => [qw/4 6 5 7/],
  e => ["8"],
  r => { 
         r => "9"  ,
         t => "10" ,
         y => "11" ,
      } ,
);

traverse { return if /ARRAY/; print "$a => $b\n" if /HASH/ && $b > 8 } \%test_hash;

```

**Output**:

```
t => 10
y => 11

```

`$a` and `$b` are treated as special variables here (as with `sort()`) while inside the `traverse()` function. `Data::Traverse` is a very simple but immensely useful module with no non-CORE dependencies.