in reply to Re: Convert delimited string into nested data structure
in thread Convert delimited string into nested data structure
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Convert delimited string into nested data structure
by eric256 (Parson) on Feb 19, 2007 at 19:32 UTC | |
by Anonymous Monk on Feb 19, 2007 at 20:04 UTC | |
by Anonymous Monk on Feb 19, 2007 at 20:25 UTC | |
|
Re^3: Convert delimited string into nested data structure
by Anonymous Monk on Feb 19, 2007 at 19:01 UTC | |
by blazar (Canon) on Feb 20, 2007 at 13:00 UTC |