Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Compare all array values without a loop

by ihb (Deacon)
on Oct 20, 2004 at 00:21 UTC ( #400714=note: print w/replies, xml ) Need Help??


in reply to Re: Compare all array values without a loop
in thread Compare all array values without a loop

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

defined( defined $foobar ? first { $_ eq $foobar } @array : first { not defined $array[$_] } 0 .. $#array )
instead.

ihb

See perltoc if you don't know which perldoc to read!
Read argumentation in its context!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://400714]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2018-07-20 19:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (439 votes). Check out past polls.

    Notices?