in reply to How to create nesting hashes given the innermost value and an array of keys?

Input in @a, output in $last[-1].
use Data::Dumper; $Data::Dumper::Deepcopy = 1; my @a = qw/foo bar baz/; my @last = (1); push @last, { $_ => $last[-1] } foreach reverse @a; print Dumper( $last[-1] ); # result
I use Data::Dumper just to print the output. It is not required to obtain the result. Output:
$VAR1 = { 'foo' => { 'bar' => { 'baz' => 1 } } };