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

Re: OR sequence

by chargrill (Parson)
on Mar 21, 2008 at 22:18 UTC ( #675540=note: print w/ replies, xml ) Need Help??


in reply to OR sequence

You can't do that.

You'll need something like:

for my $item( @FORM{ qw/Comments addr name/ } ){ if( $item =~ m/http|html|A HREF/i) { &html_message; } }

Other notes: you don't need the HTML and html with the /i at the end of your regex

Your test for HTML is a little naive.

Your test was just testing:

if( there's anything in Comments or there's anything in addr or name matches regex ){ &html_message; }

--chargrill
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)


Comment on Re: OR sequence
Select or Download Code
Re^2: OR sequence
by hipowls (Curate) on Mar 21, 2008 at 22:32 UTC

    This will call &html_massage multiple times if more than one of the three items match. That may not be the OP's intent. To call &html_massage only once modify the loop to

    ITEM: for my $item( @FORM{ qw/Comments addr name/ } ){ if( $item =~ m/http|html|A HREF/i) { &html_message; last ITEM; } }

Re^2: OR sequence
by ikegami (Pope) on Mar 21, 2008 at 22:39 UTC
    You need a last in your if to avoid calling html_message three times.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2014-04-19 22:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls