This should do the trick:
my $r; ... while( <> ) { chomp; $r = insert($r, split /[-_.]/, $_); } sub insert { my $r = shift; my $last = \$r; $last = \$$last->{$_} for @_; $$last ||= 1; $r; }
edit: fixed up call to insert()
- another intruder with the mooring in the heart of the Perl
In reply to Re: delimited strings into a hash of hashes
by grinder
in thread delimited strings into a hash of hashes
by blahblah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |