sub build { my $ref = shift; my $keys = shift; my $key = shift @$keys; # only one left in keys. that must be the value. if ( @$keys == 1 ) { $ref{$key} = $keys->[0]; } else { $ref{$key} = {} unless defined $ref{$key}; build($ref{$key}, $keys); } } my $hash = {}; while (<DATA>) { build($hash, split /:/); }
In reply to Re: Need some help building a data structure.
by holli
in thread Need some help building a data structure.
by yoda54
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |