in reply to Re: Appending values to existing hash key
in thread Appending values to existing hash key
Thank you for replying so fast. Yes, doing a hash of arrays did occur to me. Something along the lines -
chomp; (my $k, my @v) = /(\S*\s*\S*\s*)(\S*\s*\S*\s*)/; push @{$h{$k}} , shift @v;
But dropped the idea because I had to iterate twice:
foreach my $key (sort keys %h) { print "$key"; foreach my $a (@{$h{$key}}) { print "$a "; } print "\n"; }
But I see how in a bigger data set this should be the way to go. Checking for existence in a larger hash could be counter productive.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Appending values to existing hash key
by 2teez (Vicar) on Mar 21, 2014 at 04:11 UTC | |
by NetWallah (Canon) on Mar 21, 2014 at 04:47 UTC | |
by 2teez (Vicar) on Mar 21, 2014 at 06:56 UTC | |
by jaypal (Beadle) on Mar 21, 2014 at 04:31 UTC | |
|
Re^3: Appending values to existing hash key
by Laurent_R (Canon) on Mar 21, 2014 at 07:24 UTC | |
|
Re^3: Appending values to existing hash key
by hazylife (Monk) on Mar 21, 2014 at 10:41 UTC |