LINE: while (my $line = <$file>) { chomp $line; my @F = split /,/, $line; for my $i (1..3) { if ($F[0]+ $i == $F[1] and $F[1]+$i == $F[2]) { warn "row $.: $_\n"; next LINE; # the condition matched, go immediately to the next input line, do not print } } print $line, "\n"; }