use strict; use warnings; use Data::Dumper qw( Dumper ); my %tree; while (<DATA>) { chomp; my $p = \%tree; foreach (split(qr{\s*/\s*}, $_)) { $p = $p->{$_} ||= {}; } } print Dumper \%tree; __DATA__ one foo / bar foo / baz foo / qux / two foo / qux / three foo / qux / four five
In reply to Re^2: Convert delimited string into nested data structure
by ikegami
in thread Convert delimited string into nested data structure
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |