in reply to string containing characters
TIMTOWTDI.
use strict; use warnings; use Test::More tests => 2; my $goodstr = 'Can you suggest code to determine whether a string cont +ains all of a list of characters in any order?'; my $badstr = 'How to ask better questions using Test::More and sample +data'; my @list = qw/? s a y/; ok haschars ($goodstr, @list), 'Match'; ok !haschars ($badstr, @list), 'No match'; sub haschars { my $str = shift; for my $c (@_) { return 0 if -1 == index $str, $c; } return 1; }
See also How to ask better questions using Test::More and sample data.
🦛
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: string containing characters
by ikegami (Patriarch) on Jan 21, 2025 at 22:43 UTC | |
by hippo (Archbishop) on Jan 22, 2025 at 09:35 UTC | |
by ikegami (Patriarch) on Jan 22, 2025 at 14:46 UTC | |
by hippo (Archbishop) on Jan 22, 2025 at 15:30 UTC |