my %lookup = ( good => undef, bad => undef, iffy => undef, ); # and then within your loop next unless exists $lookup{$input};