in reply to eval on hash

Your $key doesn't work to address the hash, but this would work:
foreach (keys %{$new_hash->{key1}->{key2}->{key3}}) { print "$_ \n"; }