my @keys = qw(one two three); my $hash = 1; $hash = { $_=> $hash } for reverse @keys;