Mail::Builder::List - Helper module for handling various lists
use Mail::Builder; # Create a list that accepts Mail::Builder::Address objects my $list = Mail::Builder::List->new('Mail::Builder::Address'); # Add aMail::Builder::Address object $list->add($address_object); # Add an email (Unrecognized values will be passed to the constructor of # the type class - Mail::Builder::Address) $list->add('sasha.nein@psychonauts.org'); # Add one more email (Unrecognized values will be passed to the constructor of # the type class - Mail::Builder::Address) $list->add({ email => 'raz.aquato@psychonauts.org', name => 'Razputin'} ); # Remove email from list $list->remove('raz.aquato@psychonauts.org'); # Remove first element in list $list->remove(1); # Reset list $list->reset; # Add email $list->add('milla.vodello@psychonauts.org','Milla Vodello'); # Serialize email list print $list->join(',');
This is a helper module for handling various lists (e.g. recipient, attachment lists). The class contains convinient array/list handling functions.
my $list = Mail::Builder::List->new(Class name); OR my $list = Mail::Builder::List->new({ type => Class name, [ list => ArrayRef, ] });
This constructor takes the class name of the objects it should hold. It is only possible to add objects of the given type. It is not possible to change the assigned type later.
my $list = Mail::Builder::List->convert(ArrayRef);
Constructor that converts an array reference into a Mail::Builder::List object. The list type is defined by the first element of the array.
Returns the number of items in the list.
$obj->add(Object); OR $obj->add(Anything)
Pushes a new item into the list. The methods either accepts an object or any values. Values will be passed to the new method in the list type class.
new
Synonym for add
$obj->remove(Object) OR $obj->remove(Index) OR $obj->remove(Anything) OR $obj->remove()
Removes the given element from the list. If no parameter is passed to the method the last element from the list will be removed instead.
Removes all elements from the list, leaving an empty list.
my $list_item = $obj->item(Index)
Returns the list item with the given index.
my $list = $obj->join(String)
Serializes all items in the list and joins them using the given string.
$obj->contains(Object) or $obj->contains(Anything)
Returns true if the given object is in the list. You can either pass an object or scalar value. Uses the compare method from the list type class.
Returns the class name which was initially passed to the constructor.
Raw list as list or array reference.
Maroš Kollár CPAN ID: MAROS maros [at] k-1.com http://www.k-1.com
To install Mail::Builder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mail::Builder
CPAN shell
perl -MCPAN -e shell install Mail::Builder
For more information on module installation, please visit the detailed CPAN module installation guide.