my $field = 5; # the field to compare open(FIRST, "> $file1") or die "Can't open $file1: $!"; open(SECOND, "> $file2") or die "Can't open $file2: $!'; while (defined(my $first = ) { defined(my $second = ) or last; my @first = split(/\|/, $first); my @second = split(/\|/, $second); if ($first[$field] eq $second[$field]) { # mark match } else { # mark no match } }