if (grep { $_ eq $item3 } ($item1, $item2)) { #do something } #### if ($item1 eq $item3 or $item2 eq $item3) { ... }