G'day jpys,
This does what you asked for:
#!/usr/bin/env perl use strict; use warnings; my $string = '2cat6'; my @chars = split //, $string; my @tests = qw{2cat6 cat catch vwxyz 12345 67890 13457}; TEST: for my $test (@tests) { for my $char (@chars) { if (0 <= index $test, $char) { print "$test: true\n"; next TEST; } } print "$test: false\n"; }
Output:
2cat6: true cat: true catch: true vwxyz: false 12345: true 67890: true 13457: false
— Ken
In reply to Re: Finding a partial match
by kcott
in thread Finding a partial match
by jpys
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |