elsif ( $input ne 'good' and $input ne 'bad' and $input ne 'iffy' ){ next; } #### elsif ( $input !~ /good|bad|iffy/ ){ next; } #### my %lookup = ( good => undef, bad => undef, iffy => undef, ); # and then within your loop next unless exists $lookup{$input};