I would probably just use grep to get a list of the missing items.
Or use List::Util's first, which will abort the search once one is missing.my @words = qw( foo bar ); while (my $line = <DATA>) { chomp $line; my @missing = grep {$line !~ $_} @words; printf "line: %-10s; missing: %s\n", $line, join ',', @missing; } __DATA__ foo bar foo bar
Note that this will only return the first missing item, and if you're searching for something like "0" then you should check whether $has_missing is defined.use List::Util qw( first ); my @words = qw( foo bar ); while (my $line = <DATA>) { chomp $line; my $missing = first {$line !~ $_} @words; printf "line: %-10s; missing: %s\n", $line, $missing; } __DATA__ foo bar foo bar
In reply to Re: Need RegExp help - doing an AND match - use grep instead
by imp
in thread Need RegExp help - doing an AND match
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |