foreach my $line (@lines) { next if ($line !~ m/red/ || $line !~ m/blue/ || $line =~ m/green/); }