if ($third_char ne 'c' && $third_char ne 'd'){ $part=substr($stri,0,2); #### my $regexStr = join("|", @one); my $regex = qr/^$regexStr$/; ... if ($second_char =~ $regex) { ...