my %in_set; undef @in_set{1, 3, 7}; if( exists $in_set{ $x } ) { # ... }