From fd488a4f2328482aedd590e49d3cdcd9952df150 Mon Sep 17 00:00:00 2001 From: fukachan Date: Mon, 23 Apr 2001 08:32:44 +0000 Subject: address_clean_up() cleans up address by Mail::Header::parse(). nuke duplicated entries in the result by extrace_message_id_references(). --- fml/lib/FML/Header.pm | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'fml/lib/FML/Header.pm') 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*\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; } -- cgit v1.2.1