in reply to Dereferencing Hashes of Arrays

A hash isn't a spreadsheet, so you can't get "access" to a column. But you can add up the arrays for each key and the values for each position in the array. However, I don't really think the data structure you have is a great one. There are two issues: Here's some code:
use strict; use warnings; my @columntotals; my %sheet = (Terry => [5, 2], Doug => [4, 3], Fred => [1, 5]); print "Employee Buffalo Cleveland Total\n"; foreach my $key (keys %sheet) { my @data = @{$sheet{$key}}; my $sum = 0; $sum += $_ for @data; push @data, $sum; print "$key @data\n"; $columntotals[$_] += $data[$_] for 0 .. $#data; } print "Total @columntotals\n";

Replies are listed 'Best First'.
Re^2: Dereferencing Hashes of Arrays
by Anonymous Monk on Mar 13, 2005 at 06:42 UTC
    I read the values from a excel spreadsheet and put the values in a hash of array with employee as key and value is reference to an array of infor