in reply to Multiple Match (Sort of AND)
But even that could get ugly. Perhaps put all your combinations in an array and loop over them. You then have a chance to see which element(s) were missing.
#! /usr/bin/perl use strict; use warnings; my @combinations = qw{ scan print rinse repeat }; my @test_strings = do{local $\;<DATA>}; chomp @test_strings; for my $string (@test_strings){ my @misses; for my $ele (@combinations){ next if $string =~ /\Q$ele\E/; push @misses, $ele; } print $string, q{ -> }; if (@misses){ print qq{no matches for: @misses\n}; } else{ print qq{all matched\n}; } } __DATA__ scan and print and rinse and repeat print and scan and rinse and repeat print and scan and rinse print
scan and print and rinse and repeat -> all matched print and scan and rinse and repeat -> all matched print and scan and rinse -> no matches for: repeat print -> no matches for: scan rinse repeat
|
|---|