my %log_data; open FH, $file or die "Can't open $file: $!"; while () { my ($net_id, $mdy, $item) = split /\|/; $log_data{$net_id}{$mdy}{$item} = $_; } # Then cycle through data you're searching for # and save/process it if its in the %log_data array