in reply to Array to nested hash
my $hashref = {}; my $ref = \$hashref; for (@foo) { $ref = \$$ref->{$_}; } $$ref = 1; # or the value you want it to be print Dumper $hashref;
update: this also works if you want to insert more than one array, while the backwards approach will likely destroy previously built data structures
|
|---|