use Data::Dumper; my @asdf = (qw/A B C D E F/); my %hash; my $hr = \%hash; for(@asdf) { $hr->{$_} = { }; $hr = $hr->{$_}; } print Dumper \%hash;