in reply to Perl hashes: is there some way of adding more data to the value associated with an existing key?
use strict; use warnings; my %data; while (<DATA>) { chomp; my ($k, $v) = split; push @{$data{$k}}, $v; } use Data::Dumper; print Dumper(\%data); __DATA__ 1 A 1 B 2 B 4 X 5 V
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl hashes: is there some way of adding more data to the value associated with an existing key?
by locked_user sundialsvc4 (Abbot) on Jun 07, 2011 at 19:54 UTC |