in reply to Smartmatch alternatives
Can['t] use the exists() function either, because it's use on arrays is deprecated as well.
It wouldn't help any way. exists on an array only tests if the array element at a given index exists (ie. has not been deleted), and has nothing to do with what it contains.
Is there a proper, future-proof alternative that does not require me to sprinkle foreach test loops all over the place?
Like this:
if( grep /^\Q$scalar$/, @array ) { ## it's in there }
Of course, that uses the implicit $_; so perhaps you'd prefer:
if( grep $_ eq $scalar, @array ) { ## it's in there }
|
|---|