my $regexStr = join("|", @one); my $regex = qr/^$regexStr$/; ... if ($second_char =~ $regex) { ...