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 11: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!