use Data::Dumper; ## japhy's solution, with a style contribution from Juerd my @keys = qw( this that those ); my $node = \\my %hash; $node = \$$node->{$_} for @keys; $$node = 'value'; print Dumper(\%hash); __output__ $VAR1 = { 'this' => { 'that' => { 'those' => 'value' } } };