in reply to Convert delimited string into nested data structure

Actually I think OP is right to identify this as a recursion problem given the arbitrary number of levels and I feel one should not question the requirement just to make the solution seem easier (an illusion in this case anyway). My own take on this is that the recursive routine needs to be given the array reference that relates to the corresponding depth in the structure, something like: (untested)
my @result; while( <> ) { chomp(); my @fld = split /\s*\/\s*/; InsertFlds( \@result, @fld ); } sub InsertFlds { my $aref = shift; my $name = shift; defined ($aref -> [ $#$aref ]{ name }) or push @$aref, { name => $n +ame }; if ( @_ ) { $aref -> [ $#$aref ]{ children } ||= []; InsertFlds( $aref -> [$#$aref ]{ children }, @_ ); } }

-M

Free your mind