Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Compare all array values without a loop

by rjbs (Pilgrim)
on Oct 19, 2004 at 14:22 UTC ( #400537=note: print w/ replies, xml ) Need Help??


in reply to Compare all array values without a loop

if (grep({ $_ eq $foobar } @array) == @array) { ... }
"If the number of elements equal to $foobar is the same as the number of elements in the array..." or
unless (grep { $_ ne $foobar} @array) { ... }
"Unless you find an element that is not equal to foobar..."

Of course, these are both loops of a kind.
rjbs


Comment on Re: Compare all array values without a loop
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://400537]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2015-07-28 18:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls