if (grep {$a == $_} (3,77,8)) {...} # If any of them match. if (!grep {$a == $_} (3,77,8)) {...} # If none of them match. if (0 == grep {$a == $_} (3,77,8)) {...} # Same as above but more explicit. if (3 == grep {$a != $_} (3,77,8)) {...} # Also if none of them match, but maybe harder to follow.