in reply to This "each" goes to endless loop each time...

The state of the each operator is bound to a single hash. In your 2nd case you call &e for each iteration. That yields a new hash each time. So the each operator sees a new hash in every iteration. You may try a for loop:
for( my $h=&e; my ($k, $v)=each %$h; ) {...}