LINE: while (<>) { my ($one, $two, $test_name, @remaining) = split; for ($one, $two) { next LINE unless $_ eq 'N/A' or /^\d+$/; } next unless $test_name =~ /^\w+$/; # process line }