http://www.perlmonks.org?node_id=983426

Ratazong has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I want to check if a value is inside a set of predefined values. Which is the best way to do so? I came to the following solution, but somehow I have the feeling there must be a more elegant way...

my $var = "apple"; if (exists( { banana => 1, plum => 1, apple => 1, strawberry => 1, pea + => 1,}->{$var} )) { print "yes!\n"; } else { print "no.\n"; }
Rata (failing to google it himself)