in reply to Hash of Arrays
So what's the problem you are having? It's not well-stated here. Do you need help on how to use a Hash of Hashes instead?
Output:use strict; use warnings; use feature 'say'; use Data::Dumper; my %hoh; while (my $line = <DATA>) { chomp($line); my ($key, $height, $color, $weight) = split(' ', $line); @{ $hoh{$key} }{qw/height color weight/} = ($height, $color, $weig +ht); } say Dumper \%hoh; __DATA__ ef56 2.6 red 4 ef42 2.8 green 3
$VAR1 = { 'ef56' => { 'color' => 'red', 'weight' => '4', 'height' => '2.6' }, 'ef42' => { 'height' => '2.8', 'weight' => '3', 'color' => 'green' } };
Hope this helps!
|
|---|