in reply to Array to nested hash

Somewhat cleaner recursion here..
use Data::Dumper; my $a; sub x{ my $ar=$_[1]; my $v=shift @$ar or return $_[0]=undef; x($_[0]->{$v} , $ar) }; x($a,[5,3,4,5,6]); print Dumper \$a;
Prints..
$VAR1 = \{ '5' => { '3' => { '4' => { '5' => { '6' => undef } } } } };

    Earth first! (We'll rob the other planets later)