while (){ my @ju = split /\s+/, $_; push @{ $self->{code}{$ju[0]} }, { event => $ju[1], month => $ju[2], am => $ju[3], pm => $ju[4], }; } print Dumper $self->{code}; __END__ # trimmed down example output $VAR1 = { 'RF858' => [ { 'am' => '7.22', 'event' => 'U888', 'pm' => '4.20', 'month' => 'Dec' } ], 'VS524' => [ { 'am' => '5.94', 'month' => 'Jan', 'pm' => '9.46', 'event' => 'U509' }, { 'am' => '5.22', 'month' => 'Aug', 'pm' => '1.78', 'event' => 'U14' } ], }; #### for my $top_key (keys %{ $self->{code} }){ print "$top_key\n"; for my $href (@{ $self->{code}{$top_key} }){ for (keys %$href){ print "\t$_ => $href->{$_}\n"; } print "\n"; } }