my %hash = (foo => {}); my $ref = \%hash; for (0..100000) { print $_, " "; $ref = $ref->{foo}; $ref->{foo} = {}; }