Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: OR sequence (ARRAY ~~ /PATTERN/)

by lodin (Hermit)
on Mar 21, 2008 at 22:58 UTC ( #675549=note: print w/replies, xml ) Need Help??


in reply to OR sequence

One way of doing it is

if (grep { /http|html|a href/i } $FORM{'Comments'}, $FORM{'addr'}, $FO +RM{'name'}) { ... }
In Perl 5.10 that can be written as
if ([ $FORM{'Comments'}, $FORM{'addr'}, $FORM{'name'} ] ~~ /http|html| +a href/i) { ... }
which is pretty close to how you tried to write it. The latter is also slightly more efficient for large lists, as it stop to look in the list as soon as it finds a match, in contrast to grep which searches the whole list.

lodin

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2023-09-25 17:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?