in reply to Making a two dimensional hash with first row and column as the keys
use warnings; use strict; my $hdr = <DATA>; my @cols = split /\s+/, $hdr; my %hash; # pick a better name while (<DATA>) { my ($row, @vals) = split; for my $i (0 .. $#vals) { $hash{$row}{$cols[$i+1]} = $vals[$i]; } } print "$hash{aaa}{baz}\n"; __DATA__ Log foo bar baz aaa 123 456 789 bbb 987 654 321
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Making a two dimensional hash with first row and column as the keys
by AnomalousMonk (Archbishop) on Jul 06, 2011 at 18:38 UTC | |
|
Re^2: Making a two dimensional hash with first row and column as the keys
by limzz (Novice) on Jul 06, 2011 at 14:56 UTC |