Do it backwards.
use strict; use warnings; use Data::Dumper; my @foo = qw/1 2 3 4 5 6/; my $href; foreach my $key ( reverse @foo ) { $href = { $key, $href }; } print Dumper $href;
This also turns out to be very similar to one of the easiest ways in Perl to build a traditional ( in the tradition of computer science ) linked list.
Dave
In reply to Re: Array to nested hash
by davido
in thread Array to nested hash
by amw1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |