use List::Util "any"; if (any { $name eq $_ } $t1, $t2) { ...; }