in reply to Re: How to find out if X is an element in an array?
in thread How to find out if X is an element in an array?
Here is the equivalent code, using grep:
The "scalar" isnt really necessary, but it documents the fact that grep is called in a scalar context.$X = "x"; @array = qw / x y z 1 2 3 /; return scalar grep(/^$X$/,@array) > 0;
|
|---|