Assuming that $foobar isn't undefined you should have a definedness check for the return value of first too. $foobar may be 0 or "".
If undef is allowed as comparision value, use
instead.defined( defined $foobar ? first { $_ eq $foobar } @array : first { not defined $array[$_] } 0 .. $#array )
ihb
See perltoc if you don't know which perldoc to read!
Read argumentation in its context!
In reply to Re^2: Compare all array values without a loop
by ihb
in thread Compare all array values without a loop
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |