I'm surprised to see only grep examples with "eq". You can also do this with regex interpolation (being careful to match the whole thing, of course):
print "found!" if grep(/^$e$/, @a);
This might be useful if, for example, you didn't care about matching case:
print "found!" if grep(/^$e$/i, @a);
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|