in reply to Re: Convert XML to Hash
in thread Convert XML to Hash
(update: but it seems like the OP really wants a hash-of-hashes, as suggested in the first reply above, rather than a hash-of-arrays.)# for a simple case, where input is just a "key value" list, and # when any key is repeated, we want to keep all its values in an array +: my %hash; while (<>) { my ( $k, $v ) = split; push @{$hash{$k}}, $v; } for my $k ( keys %hash ) { print "$k occurred ". scalar @{$hash{$k}} ." times\n"; }
|
|---|