In the quest to make my data more accessible, I want to store my tabulated data in a complex hash. I am trying to grow a \'HoHoHoA\' as the script loops over my data. As per
I hope the following program populates the data structure you want:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
open my $fh, '<', 'input' or die $!;
my @headers;
for ( split /\t/, ~~ <$fh> ) {
chomp;
push @headers, $_ unless /^\t?$/;
}
my %monthData;
while (<$fh>) {
my @line;
for ( split /\t/ ) {
chomp;
push @line, $_ unless /^\t?$/;
}
for my $i ( 2 .. $#headers ) {
my ($hour) = split /:/, $line[1];
push @{ $monthData{ $headers[$i] }->{ $line[0] }->{$hour} }, $line[$i];
}
}
print Dumper \%monthData;