Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: "Or" in Array

by injunjoel (Priest)
on Jul 24, 2008 at 00:20 UTC ( #699735=note: print w/replies, xml ) Need Help??

in reply to "Or" in Array

Greetings, You can use grep to see if the value is in there. For example...
#!/usr/bin/perl -w use strict; #make up some data my @arr1 = 1 .. 100; my @arr2 = 0 .. 300; my @arr3 = reverse(@arr1); my @arr4 = 5 .. 10; #test it. if(grep($_ == 0, (@arr1,@arr2,@arr3,@arr4))){ print "Found it!"; }else{ print "no dice!"; }
this prints
Found it!

"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://699735]
[james28909]: i need to fix this issue with perlmonks. i keep having the issue of someone posting something that casues the page to be very wide.
[james28909]: is there some setting i am missing?
[GrandFather]: It's either lines that your browser won't split (no white space) or nodes with <pre> tags which ought to be code tags

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2017-05-24 00:56 GMT
Find Nodes?
    Voting Booth?