#!/usr/bin/perl use strict; use warnings; my %data; while (<DATA>) { chomp; my ($team, @field) = split; push @{ $data{$team} }, \@field; }
This creates a single hash entry for each team. The value is a reference to an array of all entries for that team. Each entry is an array reference to the specific stats for that entry.
Alternatively, you could do the HoHoA. Added implementation below.
#!/usr/bin/perl use strict; use warnings; use constant TEAM => 0; use constant POINTS => 1; use constant TALLIES => 2; use constant SCORES => 3; use constant METRICS => 4; my %data; while (<DATA>) { chomp; my @col = split; push @{ $data{$col[TEAM]}{POINTS} }, $col[POINTS]; push @{ $data{$col[TEAM]}{TALLIES} }, $col[TALLIES]; push @{ $data{$col[TEAM]}{SCORES} }, $col[SCORES]; push @{ $data{$col[TEAM]}{METRICS} }, $col[METRICS]; }
Cheers - L~R
In reply to Re: Need Help With Syntax for (Complicated for Me) Data Structure
by Limbic~Region
in thread Need Help With Syntax for (Complicated for Me) Data Structure
by o2bwise
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |