See METHODS in Mail::Reporter
The header maintains a list of fields which are ordered in sequence of definition. It is required to maintain the header order to keep the related fields of resent groups together. The fields are also included in a hash, sorted on their name for fast access.
The references to field objects in the hash are real, those in the ordered list are weak. So when field objects are removed from the hash, their references in the ordered list are automagically undef'd.
When many fields are removed, for instance with removeFields() or removeFieldsExcept(), then it is useful to remove the list of undefs from the ordered list as well. In those cases, this method is called automatically, however you may have your own reasons to call this method.
Remove the fields from the header which are exactly named 'STRING' (case insensitive) or match the REGular EXPresssion. Do not forget to add the 'i' modifier to the REGEXP, because fields are case insensitive.
See also removeField() which is used to remove one field object from
the header. The reverse specification can be made with
removeFieldsExcept()
.
$head->removeFields('bcc', 'received'); $head->removeFields( qr/^content-/i );
Remove all fields from the header which are not equivalent to one of the specified STRINGs (case-insensitive) and which are not matching one of the REGular EXPressions. Do not forget to add the 'i' modifier to the REGEXP, because fields are case insensitive.
See also removeField() which is used to remove one field object from
the header. The reverse specification can be made with removeFields()
.
$head->removeFieldsExcept('subject', qr/^content-/i ); $head->removeFieldsExcept( qw/subject to from sender cc/ );
Removes all header lines which are used to administer mailing lists. Which fields that are is explained in Mail::Message::Head::ListGroup. Returned is the number of removed lines.
Removes all header lines which are member of a resent group, which are explained in Mail::Message::Head::ResentGroup. Returned is the number of removed lines.
For removing single groups (for instance because you want to keep the last), use Mail::Message::Head::FieldGroup::delete().
Removes all header lines which were produced by spam detection and spam-fighting software. Which fields that are is explained in Mail::Message::Head::SpamGroup. Returned is the number of removed lines.