Regular Expressions

Daniel Walmsley daniel at
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
	$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.


-----Original Message-----
From: Scott Penrose [mailto:scottp at] 
Sent: Friday, 12 April 2002 3:06 PM
To: melbourne-pm at
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  Admin request: 

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


> Reply-To: "Andrew Gray" <sysadmin at>
> From: "Andrew Gray" <agray at>
> To: <melbourne-pm at>
> 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,
> 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
> Andrew
Scott Penrose
Open source and Linux Developer
scottp at

More information about the Melbourne-pm mailing list