Something like this? I faked an input file because you did not include a valid input file.
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11132513 use warnings; my %hash; while( <DATA> ) { my ( $top, @rest ) = split /,|\n/; # FIXME faking CSV for testing $hash{$top} = chain(@rest); } use Data::Dump 'dd'; dd \%hash; sub chain { return @_ > 1 ? { shift() => chain(@_) } : shift(); } __DATA__ a,b,c,d,e f,g,h,i,j xx,yy,zz this,is,a,strange,type,of,data,organization
Outputs:
{ a => { b => { c => { d => "e" } } }, f => { g => { h => { i => "j" } } }, this => { is => { a => { strange => { type => { of => { data => "organizatio +n" } } } }, }, }, xx => { yy => "zz" }, }
In reply to Re: Creating a Multi Level Hash from CSV
by tybalt89
in thread Creating a Multi Level Hash from CSV
by workInProgress12
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |