array search in perl using grep
by rajesh[ Edit ] 2008-11-19 21:10:34
We can use grep in a if condition to check whether a string is in a array
Example:
@arrayy = ('search 1', 'search 2', 'search 3', 'search 4');
$test="search 2"
if (grep {$_ =~ $test} @arrayy) {
print "found";
}