@line = split /\r/m, $file; for my $line (@line) { my $header = ((split(/\t/, $line))[0]); ##stuck here as I was unsure how to compare $header to previously seen header }