in reply to Search for array element
if(grep(/\Q$val1\E/i,@arr1))
For more information, read up on String interpolation and Regular Expressions.
Update: Upon a little further reflection, perhaps you mean
if(grep($val1 =~ /$_/i,@arr1)) { print "Value is present\n" ; } else { print "Value is not present\n"; }
|
|---|