in reply to Need some help building a data structure.

The natural way is of course recursion.
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 /:/); }


holli

When you're up to your ass in alligators, it's difficult to remember that your original purpose was to drain the swamp.