Or you could do it functionally rather than explicit recursion using List::Util's reduce (not that that's likely to be of any help to trolls who're unfamiliar with a bog simple recursive sub . . .).

## (reduce #(hash-map %2 %1) 1 (reverse [:foo :bar :baz :quux])) use List::Util qw( reduce ); use Data::Dumper qw( Dumper ); my $hash = reduce { +{ $b => $a } } 1, reverse( qw( foo bar baz quux ) + ); say Dumper( $hash ); __END__ $VAR1 = { 'foo' => { 'bar' => { 'baz' => { 'quux' => '1' } } } };

The cake is a lie.
The cake is a lie.
The cake is a lie.


In reply to Re^2: Creating a Multi Level Hash from CSV by Fletch
in thread Creating a Multi Level Hash from CSV by workInProgress12

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":