in reply to map to hash of arrays
Is it what you want?
use Data::Dumper; my $data = <<EOT; Row 1 label1 : item1 label2 : item1 Row 2 label1 : item2 label2 : item2 EOT push @{$hash{$1}}, $2 while $data =~ /(\S+)\s*:\s*(\S+)/g; print Dumper(\%hash);
$VAR1 = { 'label1' => [ 'item1', 'item2' ], 'label2' => [ 'item1', 'item2' ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: map to hash of arrays
by emilford (Friar) on Jul 26, 2004 at 14:12 UTC | |
by ccn (Vicar) on Jul 26, 2004 at 14:26 UTC | |
by emilford (Friar) on Jul 27, 2004 at 13:51 UTC |