my @report; while (my $line = <$log_file>) { my @fields = (split / /, $line); $report[$_]{$fields[$_]}++ for 2,4,5,9,7,1; } #### use strict; use warnings; use Data::Dump qw/dd/; my %report; while (my $line = ) { next if $line =~ /^\s*$/; # skip empty lines my @fields = (split / /, $line); $report{$_}{$fields[$_]}++ for 2,4,5,9,7,1; } dd \%report; __DATA__ 483 OS dx-32 1 charles list4 aardvark.com ty-off lx-on C 01 483 DS dx-14 1 james list3 23.456.12.7 ty-on lx-on B 01 769 XO dx-32 5 sully nolist widgets.com ty-on lx-on V 07 #### { 1 => { DS => 1, OS => 1, XO => 1 }, 2 => { "dx-14" => 1, "dx-32" => 2 }, 4 => { charles => 1, james => 1, sully => 1 }, 5 => { list3 => 1, list4 => 1, nolist => 1 }, 7 => { "ty-off" => 1, "ty-on" => 2 }, 9 => { B => 1, C => 1, V => 1 }, }