use strict; use warnings; my $addr_pattern = qr/\s*?(?:\w+\.?)*\@(?:\w+\.?)*\s*?/; my $name_pattern = qr/(?:(?:\w+\s+)*\w+)/; my @valid_patterns = ( qr/$addr_pattern/, qr/$name_pattern\s+<$addr_pattern>/, qr/<$addr_pattern>\s+$name_pattern/, ); my $all = join '|', @valid_patterns; while (<DATA>) { chomp; my ($addr) = /^(\s*?($all)),?/; print "$addr\n"; } __DATA__ Xung03 <xung03@aol.com> To: xung03@aol.com From: ... xung03@aol.com To: xung03@aol.com From: ... <xung03@aol.com> Xung03 XMS To: xung03@aol.com From: ... <xung03@aol.com> Xung03 XMS, To: xung03@aol.com From: ... foo_bar@aol.com Xung 03 <foo_bar@aol.com>
Xung03 <xung03@aol.com> xung03@aol.com <xung03@aol.com> Xung03 XMS To <xung03@aol.com> Xung03 XMS foo_bar@aol.com Xung 03 <foo_bar@aol.com>
In reply to Re: preventing malicious mail attacks
by Roger
in thread preventing malicious mail attacks
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |