#!/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"; } #### 2cat6: true cat: true catch: true vwxyz: false 12345: true 67890: true 13457: false