in reply to Re^2: Parse a file into a hash
in thread [Resolved] Parse a file into a hash
You should probably show us some sample data, so we can tell what "can't detect a key" means. But in general, you're talking about creating a hash of arrays. So for every key/value pair, you'll want to do something like this:
push @{$stack{$key}}, $value;
That pushes the value onto the array referenced by the key within the hash. Later, you'll be able to go through them with:
for my $key (keys %stack){ for my $value (@{$stack{$key}}){ # do stuff with $key and $value } }
Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Parse a file into a hash
by kazak (Beadle) on Apr 06, 2012 at 14:50 UTC | |
by mendeepak (Scribe) on Apr 07, 2012 at 05:55 UTC | |
by kazak (Beadle) on Apr 09, 2012 at 14:43 UTC |