Regular Expressions

Daniel Walmsley daniel at landmarksoftware.com.au
Fri Apr 12 02:38:38 CDT 2002


What about something like:

my @exceptions; #list of addresses that are exceptions to the rule
my $in_mail; #the mail you received
my $in_address; #address of the mail you received

unless ( { 
	my $filter=0; #0 if no exception was found, 1 if the $in_address is
an exception
	foreach (@exceptions) {
		if(/^$in_address$/) { #if the in address matches an
exception
			$filter=1;
		}
	$filter; #return the value of $dont_filter
	} ) {
	if(/.*[0-9]{5,10}\@aol.*/) {
		throw_away_mail_from $in_mail; #call some function that
throws away the e-mail
	}
}

There's probably a bug in there somewhere... and I should be breaking out of
the foreach when I set $dont_filter, but I can't remember how (is there a
break statement in Perl). But that's the idea, I would guess.

Dan	

-----Original Message-----
From: Scott Penrose [mailto:scottp at dd.com.au] 
Sent: Friday, 12 April 2002 3:06 PM
To: melbourne-pm at pm.org
Subject: Fwd: Regular Expressions


Hey guys

No idea why but this message got bounced to me (owner currently of 
melbourne-pm) because it contained the word 'help' somewhere in the title
Literally I received:
	Subject: BOUNCE melbourne-pm at pm.org:  Admin request: 
/^subject:\s*help\b/i

Anyway, it is of course a legitimate question so here it is...

Scott

> Reply-To: "Andrew Gray" <sysadmin at netconnect.com.au>
> From: "Andrew Gray" <agray at netconnect.com.au>
> To: <melbourne-pm at pm.org>
> Subject: Help with regular expressions
> Date: Thu, 11 Apr 2002 10:07:29 +1000
>
> Hi guys/gals,
>
> I have an anti spam filter that uses regular expressions to take out
> mail
> based on From: addresses
>
> an example is
> .*[0-9]{5,10}\@aol.*
>
> which filters all spammer type addresses like fred123456789 at aol.com,
> but I
> have a very few addresses that it is catching that I would like to let
> through, so my question is, how can I write a rule with exceptions
>
> ie ban *123456789 at aol.* except LauraK894820558 at aol.com
>
> Andrew
---
Scott Penrose
Open source and Linux Developer
http://linux.dd.com.au/
scottp at dd.com.au



More information about the Melbourne-pm mailing list