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


Mail::AddressSort Sort an array of email addresses





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


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:, chrisj@MR.Net

are reversed for the purposes of sorting to:




Creates a new AddressSort object.


Adds addresses to the internal table.


Returns a single list of addresses sorted out.


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.


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.


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


Chris Josephes (


Version 1.0