team_1, location_2, tool_1, 4
team_3, location_1, tool_3, 3
team_2, location_3, tool_3, 2
team_2, location_4, tool_2, 5
team_3, location_2, tool_5, 3
team_1, location_1, tool_3, 1
team_2, location_4, tool_5, 6
team_4, location_2, tool_5, 3
team_5, location_4, tool_4, 2
team_2, location_4, tool_5, 3
team_3, location_3, tool_4, 4
team_2, location_4, tool_5, 3
team_4, location_1, tool_1, 1
team_1, location_3, tool_5, 3
team_3, location_2, tool_5, 5
####
use v5.14;
use Data::Dumper;
my %locHash;
foreach(`cat dataFile`){
my ($locName, $toolName, $toolNum)=(split(/\,/,))[1..3];
$locHash{$locName}->{$toolName}=$toolNum;
}
print "Data::Dumper:\n";
print Dumper(\%locHash);
say "";
foreach my $locName(sort keys %locHash){
say " ";
say " ",chomp($locName),"";
say " ";
foreach my $toolDetail(sort keys %{$locHash{$locName}}){
say " ";
say " ",chomp($toolDetail),"";
say " ",chomp($locHash{$locName}->{$toolDetail}),"";
say " ";
say " ";
}
say "";
####
Data::Dumper:
$VAR1 = {
' location_1' => {
' tool_3' => ' 1
',
' tool_1' => ' 1
'
},
' location_3' => {
' tool_5' => ' 3
',
' tool_3' => ' 2
',
' tool_4' => ' 4
'
},
' location_4' => {
' tool_5' => ' 3
',
' tool_2' => ' 5
',
' tool_4' => ' 2
'
},
' location_2' => {
' tool_5' => ' 5
',
' tool_1' => ' 4
'
}
};
0
0
1
0
1
0
0
1
0
1
0
0
1
0
1
0
1
0
0
1
0
1
0
1