in reply to check if a value is in a given set

I want to check if a value is inside a set of predefined values.

I would use grep.

#!/usr/bin/perl -w use strict; my @fruits = qw(banana plum apple strawberry pea); if ( grep {/apple/}@fruits ) #perhaps /^apple$/ { print "apple found!\n"; } else { print "apple not fouund\n"; } __END__ apple found!
There are other ways see: List::Util