my %hash; $hash{key}{subkey}=123; my $f= $hash{key}; $hash{key}= undef; #moving the subhash print $f->{subkey}; #would print 123