Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Think about Loose Coupling
 
PerlMonks  

Re: If Simplification

by dbwiz (Curate)
on Aug 07, 2003 at 06:59 UTC ( [id://281836]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to If Simplification

You can create a sub to check for an array of values that must not be inside a given string. This way, if you have more values, you can just add them to your array.

sub absent { my $str = shift; for (@_) { return 0 if $str =~ $_ } return 1; } my @must_not_be_there = ( '/bulletin/', '.css', 'formmail.', '/prosp/', '/calendar/', '/edit/', '/tmp/calendar2002-3/pgradh/regs/029.html', 'FalseIfJustThis', 'ButIfAlsoThisThenTrue' ); if (($ENV{'HTTP_REFERER'} && $ENV{'REMOTE_ADDR'} ne "129.215.67.96") && absent ($ENV{'REQUEST_URI'}, @must_not_be_there) ) { print "matches\n"; }

Or simply use grep.

&& !(grep {$ENV{'REQUEST_URI'} =~ $_} @must_not_be_there ) )

Replies are listed 'Best First'.
Re: Re: If Simplification
by fourmi (Scribe) on Aug 07, 2003 at 07:27 UTC
    Cool, the array idea sounds simple for my head, I'd need to have a think about how to get the pseudocode bit incorporated, ie, 'falseifjustthis' is allowed, but only if 'butifalsothisthentrue' is also there. Should be able to cope though! Exercise left to the reader, as they say!
    cheers!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://281836]
help
Sections?
Information?
Find Nodes?
Leftovers?
    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.