I see your updates. BTW, when you update your post, it is good form to preserve the original version so later readers can figure out what is going on. You can "hide" say a previous section with <readme> <readmore>tags. Note: I made a typo and works out to be a demo of method of updating a post...the <strike> tags!

I am still confused by this: Important to note that there are repeated values, which is the case for the provided sample output, (ie info 01 = info11, info02 = info12, etc.), but this is not always the case.. As you can see there have been multiple interpretations of your problem statement. My interpretation is shown below which allows for duplicated values in the CSV line(s).

In general, the more you tell us about your problem, the more helpful the Monks can be. I didn't understand any more about what you are actually doing with this data structure. You may find that is a very awkward thing to work with.

I would be curious to know how close my "crystal ball" got.

use strict; use warnings; use Data::Dumper; my %hash; foreach my $line (<DATA>) #simulated simple CSV file { my @cols = (split /,|\n/,$line); my $href = \%hash; while (my $col = shift @cols) { $href->{$col} = {} unless (exists ($href->{$col}) and keys %{$href->{$col}} ); $href = $href->{$col}; } } print Dumper \%hash; =OUTPUT: $VAR1 = { 'x' => { '5' => { '6' => {} } }, 'a' => { 'x' => { 'e' => {}, 'm' => {}, 'c' => {} }, 'b' => { 'c' => {} }, 'y' => { 'h' => {} } } }; =cut __DATA__ a,x,c a,x,e a,y,h a,x,m a,b,c x,5,6

In reply to Re^3: Creating a Multi Level Hash from CSV by Marshall
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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.