I'm still a bit vague about your requirements, but something along these lines might serve (note /g regex modifier is required in m{ ... }xmsg below):
>perl -wMstrict -le "my @motifs = qw(WEED KILLD DIAL PIES); my $motif = join '|', @motifs; $motif = qr{ $motif }xms; ;; my $element = 'both WEED PIES and DIAL PIES are present'; ;; my %elements = map { $_ => 1 } $element =~ m{ $motif }xmsg ; ;; printf qq{$_ is %spresent \n}, $elements{$_} ? '' : 'NOT ' for @motifs; ;; my @present = keys %elements; print qq{present: @present}; " WEED is present KILLD is NOT present DIAL is present PIES is present present: WEED DIAL PIES
Update: The map statement could easily be changed to count the number of occurrences of each 'motif', if that's the correct terminology.
In reply to Re^3: and or statement
by AnomalousMonk
in thread and or statement
by endsin1m
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |