use strict; use warnings; my @wanted = (1, 2, 3, 4); for my $test ('1432', '1345', 'brown fox') { my $count = grep {$test =~ /$_/} @wanted; if ($count == @wanted) { print "'$test' contains all wanted characters\n"; } elsif ($count) { print "'$test' does not contain all wanted characters\n"; } else { print "'$test' contains no wanted characters\n"; } }