in reply to string containing characters
What have you tried? Maybe you should show us some sample code?
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"; } }
Prints:
'1432' contains all wanted characters '1345' does not contain all wanted characters 'brown fox' contains no wanted characters
Which contains some deliberate errors and should not be used for "production" code.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: string containing characters
by choroba (Cardinal) on Jan 21, 2025 at 09:32 UTC | |
Re^2: string containing characters
by ikegami (Patriarch) on Jan 21, 2025 at 22:42 UTC | |
by GrandFather (Saint) on Jan 22, 2025 at 02:31 UTC |