{
    "mode": "perldoc",
    "parameter": "Mail::Field",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Mail%3A%3AField/json",
    "generated": "2026-06-10T08:16:11Z",
    "synopsis": "use Mail::Field;\nmy $field = Mail::Field->new('Subject', 'some subject text');\nmy $field = Mail::Field->new(Subject => 'some subject text');\nprint $field->tag,\": \",$field->stringify,\"\\n\";\nmy $field = Mail::Field->subject('some subject text');",
    "sections": {
        "NAME": {
            "content": "Mail::Field - base-class for manipulation of mail header fields\n",
            "subsections": []
        },
        "INHERITANCE": {
            "content": "Mail::Field is extended by\nMail::Field::AddrList\nMail::Field::Date\nMail::Field::Generic\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Mail::Field;\n\nmy $field = Mail::Field->new('Subject', 'some subject text');\nmy $field = Mail::Field->new(Subject => 'some subject text');\nprint $field->tag,\": \",$field->stringify,\"\\n\";\n\nmy $field = Mail::Field->subject('some subject text');\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"Mail::Field\" creates and manipulates fields in MIME headers, collected within a Mail::Header\nobject. Different field types have their own sub-class (extension), defining additional useful\naccessors to the field content.\n\nPeople are invited to merge their implementation to special fields into MailTools, to maintain a\nconsistent set of packages and documentation.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "",
            "subsections": [
                {
                    "name": "Constructors",
                    "content": "Mail::Field (and it's sub-classes) define several methods which return new objects. These can\nall be categorized as constructor.\n\nMail::Field->combine($fields)\nTake a LIST of \"Mail::Field\" objects (which should all be of the same sub-class) and create\na new object in that same class.\n\nMail::Field->extract( $tag, $head [, $index ] )\nTakes as arguments the tag name, a \"Mail::Head\" object and optionally an index.\n\nIf the index argument is given then \"extract\" will retrieve the given tag from the\n\"Mail::Head\" object and create a new \"Mail::Field\" based object. *undef* will be returned in\nthe field does not exist.\n\nIf the index argument is not given the result depends on the context in which \"extract\" is\ncalled. If called in a scalar context the result will be as if \"extract\" was called with an\nindex value of zero. If called in an array context then all tags will be retrieved and a\nlist of \"Mail::Field\" objects will be returned.\n\nMail::Field->new( $tag [, STRING | %options] )\nCreate an object in the class which defines the field specified by the $tag argument.\n\n\"Fake\" constructors\n$obj->create(%options)\nThis constructor is used internally with preprocessed field information. When called on an\nexisting object, its original content will get replaced.\n\n$obj->parse()\nParse a field line.\n"
                },
                {
                    "name": "Accessors",
                    "content": "$obj->set(%options)\nChange the settings (the content, but then smart) of this field.\n\n$obj->stringify()\nReturns the field as a string.\n\n$obj->tag()\nMail::Field->tag()\nReturn the tag (in the correct case) for this item. Well, actually any casing is OK, because\nthe field tags are treated case-insensitive; however people have some preferences.\n"
                },
                {
                    "name": "Smart accessors",
                    "content": "$obj->text( [STRING] )\nWithout arguments, the field is returned as stringify() does. Otherwise, the STRING is\nparsed with parse() to replace the object's content.\n\nIt is more clear to call either stringify() or parse() directly, because this method does\nnot add additional processing.\n"
                }
            ]
        },
        "DETAILS": {
            "content": "SUB-CLASS PACKAGE NAMES\nAll sub-classes should be called Mail::Field::*name* where *name* is derived from the tag using\nthese rules.\n\n*   Consider a tag as being made up of elements separated by '-'\n\n*   Convert all characters to lowercase except the first in each element, which should be\nuppercase.\n\n*   *name* is then created from these elements by using the first N characters from each\nelement.\n\n*   N is calculated by using the formula :-\n\nint((7 + #elements) / #elements)\n\n*   *name* is then limited to a maximum of 8 characters, keeping the first 8 characters.\n\nFor an example of this take a look at the definition of the \"headerpkgname()\" subroutine in\n\"Mail::Field\"\n",
            "subsections": []
        },
        "DIAGNOSTICS": {
            "content": "Error: Undefined subroutine <method> called\nMail::Field objects use autoloading to compile new functionality. Apparently, the method\ncalled is not implemented for the specific class of the field object.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "This module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance\nwithout commitment to further development.\n\nMail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by Peter Orbaek <poe@cit.dk>.\nMail::Mailer and Mail::Send by Tim Bunce <Tim.Bunce@ig.co.uk>. For other contributors see\nChangeLog.\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2017 Mark Overmeer\n<perl@overmeer.net>.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself. See http://www.perl.com/perl/misc/Artistic.html\n",
            "subsections": []
        }
    },
    "summary": "Mail::Field - base-class for manipulation of mail header fields",
    "flags": [],
    "examples": [],
    "see_also": []
}