http://qs321.pair.com?node_id=400680

redbeard has asked for the wisdom of the Perl Monks concerning the following question:

So, I've read over explanations on making a hash of arrays and attempted to adopt the methods into a program to take a simple datafile and turn it into a hash of arrays. The file has the format
1,2 1,3 1,4 2,3 2,5 2,5
And I want to make a hash of arrays where the first column is the key and the second column is the data. I've done it like so:
local %DATAHASH; open (DATA, 'foo.csv'); while (<DATA>){ chomp; my @datarow=split(/,/, $_); push(@{$DATAHASH{$datarow[0]}}, ($datarow[1])); }
And yet, whenever I try and print out the contents of DATAHASH, either after the while loop or in its midst using Dumper($DATAHASH}, I get a $VAR1 = undef Any advice on remedying this situation? And looking further down the line, for something that will have two seperate keys (e.g. 1,2,3 is a line from the file) I'm using push( @{$DATAHASH{$datarow[0]}->{$datarow[1]}}, ($datarow[2]) );, which I'm assuming I'll just modify in the same way.