Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: using grep to match more than two words

by blazar (Canon)
on Jun 12, 2007 at 08:29 UTC ( [id://620667]=note: print w/replies, xml ) Need Help??


in reply to Re: using grep to match more than two words
in thread using grep to match more than two words

((grep/^(Sun|Moon)$/, @arr1) == 2) ? (print "True") : (print "False");

This is not reliable if @arr1 is allowed to contain duplicates, it is deemed to give false positives and false negatives, and the OP wrote nothing about that possibility.

Replies are listed 'Best First'.
Re^3: using grep to match more than two words
by parv (Parson) on Jun 13, 2007 at 05:34 UTC

    Oh Dang! I was going to post which would had counted the number of matches (did not post as similar method had already been shown) but I completely missed the possibility of duplicates. Thanks much.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2025-12-13 03:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (92 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.