diff options
| author | fukachan <fukachan> | 2001-04-23 08:32:44 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-04-23 08:32:44 +0000 |
| commit | fd488a4f2328482aedd590e49d3cdcd9952df150 (patch) | |
| tree | 2f25ea4e557d6b6e88aa6f42ac066017037003de /fml/lib/FML/Header.pm | |
| parent | 642dccde8d71f1d962abc865bdb102d69af6b548 (diff) | |
| download | fml8-fd488a4f2328482aedd590e49d3cdcd9952df150.tar.gz fml8-fd488a4f2328482aedd590e49d3cdcd9952df150.tar.bz2 fml8-fd488a4f2328482aedd590e49d3cdcd9952df150.zip | |
address_clean_up() cleans up address by Mail::Header::parse().
nuke duplicated entries in the result by extrace_message_id_references().
Diffstat (limited to 'fml/lib/FML/Header.pm')
| -rw-r--r-- | fml/lib/FML/Header.pm | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/fml/lib/FML/Header.pm b/fml/lib/FML/Header.pm index 9f49ad45..d1fffaba 100644 --- a/fml/lib/FML/Header.pm +++ b/fml/lib/FML/Header.pm @@ -5,7 +5,7 @@ # redistribute it and/or modify it under the same terms as Perl itself. # # $Id$ -# $FML: Header.pm,v 1.32 2001/04/15 05:01:58 fukachan Exp $ +# $FML: Header.pm,v 1.33 2001/04/23 04:30:28 fukachan Exp $ # package FML::Header; @@ -105,9 +105,17 @@ sub set sub address_clean_up { my ($self, $addr) = @_; + + use Mail::Address; + my @addrlist = Mail::Address->parse($addr); + + # only the first element in the @addrlist array is effective. + $addr = $addrlist[0]->address; $addr =~ s/^\s*<//; $addr =~ s/>\s*$//; - $addr; + + # return the result. + return $addr; } @@ -343,8 +351,15 @@ sub extract_message_id_references use Mail::Address; my @addrs = Mail::Address->parse($buf); - my @r = (); - foreach my $addr (@addrs) { push(@r, $addr->address);} + my @r = (); + my %uniq = (); + foreach my $addr (@addrs) { + my $a = $addr->address; + unless ($uniq{ $a }) { + push(@r, $addr->address); + $uniq{ $a } = 1; + } + } \@r; } |
