jigglermwm has asked for the wisdom of the Perl Monks concerning the following question:
Hello This seems like it should be easy, but I haven't found a nice solution yet. What is happening Basically I am receiving input where each line has an unknown number of elements separated by "/". example input line a/b/c/d/e Each input line will result in a new hash like $hash{$a}{$b}{... = value Not sure how to properly create the hash when I have an unknown number of elements per line I could put @fields through a foreach loop, but that seems like a lot of redundant hash keys created and wasted cpu cycles to get to the finial key/value assignment
while (<>) { chomp; @fields = split /\//, $_;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Assign a value to a hash of unknown nodes
by Somni (Friar) on Jul 13, 2011 at 17:13 UTC | |
by jigglermwm (Initiate) on Jul 13, 2011 at 17:22 UTC | |
|
Re: Assign a value to a hash of unknown nodes
by AnomalousMonk (Archbishop) on Jul 13, 2011 at 18:56 UTC | |
|
Re: Assign a value to a hash of unknown nodes
by Anonymous Monk on Jul 13, 2011 at 16:51 UTC | |
by jigglermwm (Initiate) on Jul 13, 2011 at 17:21 UTC | |
|
Re: Assign a value to a hash of unknown nodes
by metaperl (Curate) on Jul 13, 2011 at 21:12 UTC |