my %unmatches = ( 1 => 1, 2 => 1, 3 => 1, 4 => 1 ); unless (exists $unmatches{$sum} ) { print "didn't match!\n"; }