in reply to Variables as a variable name... (I know you shouldn't but...)
The code snippet below should get you started.
You should also have a look at perldsc and perlreftut for some basic training in complex data structures in Perl.
use strict; use warnings; use Data::Dumper; my %outputs; while ( <DATA> ) { my($day, $line, $output) = (split); $outputs{$line}{$day} = $output; } print Dumper(\%outputs); __END__ 2 CANNING 18353 2 MULTIPACK 14878 2 QUEST 911 3 CANNING 46775 3 MULTIPACK 42601 3 QUEST 1564 4 CANNING 81302 4 MULTIPACK 67542 4 QUEST 1879
$VAR1 = { 'CANNING' => { '4' => '81302', '3' => '46775', '2' => '18353' }, 'QUEST' => { '4' => '1879', '3' => '1564', '2' => '911' }, 'MULTIPACK' => { '4' => '67542', '3' => '42601', '2' => '14878' } };
|
|---|