<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># Copyrights 1995-2012 by [Mark Overmeer &lt;perl@overmeer.net&gt;].
#  For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.00.
use strict;

package Mail::Field::AddrList;
use vars '$VERSION';
$VERSION = '2.12';

use base 'Mail::Field';

use Carp;
use Mail::Address;


my $x = bless [];
$x-&gt;register('To');
$x-&gt;register('From');
$x-&gt;register('Cc');
$x-&gt;register('Reply-To');
$x-&gt;register('Sender');

sub create(@)
{   my ($self, %arg)  = @_;
    $self-&gt;{AddrList} = {};

    while(my ($e, $n) = each %arg)
    {   $self-&gt;{AddrList}{$e} = Mail::Address-&gt;new($n, $e);
    }

    $self;
}

sub parse($)
{   my ($self, $string) = @_;
    foreach my $a (Mail::Address-&gt;parse($string))
    {   my $e = $a-&gt;address;
	$self-&gt;{AddrList}{$e} = $a;
    }
    $self;
}

sub stringify()
{   my $self = shift;
    join(", ", map { $_-&gt;format } values %{$self-&gt;{AddrList}});
}


sub addresses { keys %{shift-&gt;{AddrList}} }


# someone forgot to implement a method to return the Mail::Address
# objects.  Added in 2.00; a pitty that the name addresses() is already
# given :(  That one should have been named emails()
sub addr_list { values %{shift-&gt;{AddrList}} }


sub names { map { $_-&gt;name } values %{shift-&gt;{AddrList}} }


sub set_address($$)
{   my ($self, $email, $name) = @_;
    $self-&gt;{AddrList}{$email} = Mail::Address-&gt;new($name, $email);
    $self;
}

1;
</pre></body></html>