LINE: for each line of the file { PATTERN: for each exclude string { if it matches the exclude string skip to the next PATTERN else print the line skip to the next LINE } } #### LINE: for each line of the file { PATTERN: for each exclude string { if we must exclude this line skip to the next LINE } we weren't excluded by any pattern, so print the line } #### LINE: foreach my $line (@file1only) { foreach my $exclude (@strings) { chomp $exclude; next LINE if $line =~ $exclude; } # we weren't excluded by any of the patterns print OUT $line; }