in reply to check if a value is in a given set
I would use grep.
There are other ways see: List::Util#!/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!
|
|---|