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
In reply to Re: Making a two dimensional hash with first row and column as the keys
by toolic
in thread Making a two dimensional hash with first row and column as the keys
by limzz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |