The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mail::AddressSort Sort an array of email addresses

SYNOPSIS

$list=Mail::AddressSort->new();

$list->input(@addresses);

(@addresses)=$list->sorted();

$batch=$list->batches(-maxRecipients => [int] , -byHost);

DESCRIPTION

Mail::AddressSort is useful for sorting large lists of email addresses. A Mail::AddressSort object is capable of taking an array of email addresses and returning it in either a single sorted list, or an array reference to array references that contain of the same list broken down into smaller batches.

The email addresses are sorted by taking a reverse of the fully qualified domain name instead of just using the literal string. This can be helpful in sorting the list by mailhosts.

For example, the following email addresses:

cpj1@visi.com, chrisj@MR.Net

are reversed for the purposes of sorting to:

com.visi@cpj1, net.mr@chrisj

METHODS

$list=Mail::AddressSort->new();

Creates a new AddressSort object.

$list->input([addresses]);

Adds addresses to the internal table.

(@array)=$list->sorted();

Returns a single list of addresses sorted out.

$size=$list->count();

Returns the number of addresses in the list.

$batch=$list->batches(-maxRecipients -> [int], -byHost);

Returns a pointer to an array. Each element in the array is an annonymous array containing sorted email addresses from the list. Each list will be no larger than the value passed in the -maxRecipients arguement.

The -maxRecipients option will automatically be set if it isn't specified. If the number of addresses in the list is less than 100, it will be set to 1/5th of that number. If the number of addresses is over 100, it will be set to 100.

If -byHost is specified, each list in the array will only contain email addresses with a matching FQDN.

$list->printBatches($batch,$index);

Prints out a report of the contents of batch array (created from the $list->batches method). If $index is specified, it will only print a list of addresses associated with that particular batch.

$list->printHostCount();

Prints a list of all hosts with the number of addresses associated with that host.

AUTHOR

Chris Josephes (chrisj@mr.net)

VERSION

Version 1.0