{
    "mode": "perldoc",
    "parameter": "MIME::Field::ContType",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/MIME%3A%3AField%3A%3AContType/json",
    "generated": "2026-07-05T13:46:21Z",
    "synopsis": "use Mail::Field;\nuse MIME::Head;\n# Create an instance from some text:\n$field = Mail::Field->new('Content-type',\n'text/HTML; charset=\"US-ASCII\"');\n# Get the MIME type, like 'text/plain' or 'x-foobar'.\n# Returns 'text/plain' as default, as per RFC 2045:\nmy ($type, $subtype) = split('/', $field->type);\n# Get generic information:\nprint $field->name;\n# Get information related to \"message\" type:\nif ($type eq 'message') {\nprint $field->id;\nprint $field->number;\nprint $field->total;\n}\n# Get information related to \"multipart\" type:\nif ($type eq 'multipart') {\nprint $field->boundary;            # the basic value, fixed up\nprint $field->multipartboundary;  # empty if not a multipart message!\n}\n# Get information related to \"text\" type:\nif ($type eq 'text') {\nprint $field->charset;      # returns 'us-ascii' as default\n}",
    "sections": {
        "NAME": {
            "content": "MIME::Field::ContType - a \"Content-type\" field\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "A subclass of Mail::Field.\n\n*Don't use this class directly... its name may change in the future!* Instead, ask Mail::Field\nfor new instances based on the field name!\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Mail::Field;\nuse MIME::Head;\n\n# Create an instance from some text:\n$field = Mail::Field->new('Content-type',\n'text/HTML; charset=\"US-ASCII\"');\n\n# Get the MIME type, like 'text/plain' or 'x-foobar'.\n# Returns 'text/plain' as default, as per RFC 2045:\nmy ($type, $subtype) = split('/', $field->type);\n\n# Get generic information:\nprint $field->name;\n\n# Get information related to \"message\" type:\nif ($type eq 'message') {\nprint $field->id;\nprint $field->number;\nprint $field->total;\n}\n\n# Get information related to \"multipart\" type:\nif ($type eq 'multipart') {\nprint $field->boundary;            # the basic value, fixed up\nprint $field->multipartboundary;  # empty if not a multipart message!\n}\n\n# Get information related to \"text\" type:\nif ($type eq 'text') {\nprint $field->charset;      # returns 'us-ascii' as default\n}\n",
            "subsections": []
        },
        "PUBLIC INTERFACE": {
            "content": "boundary\nReturn the boundary field. The boundary is returned exactly as given in the \"Content-type:\"\nfield; that is, the leading double-hyphen (\"--\") is *not* prepended.\n\n(Well, *almost* exactly... from RFC 2046:\n\n(If a boundary appears to end with white space, the white space\nmust be presumed to have been added by a gateway, and must be deleted.)\n\nso we oblige and remove any trailing spaces.)\n\nReturns the empty string if there is no boundary, or if the boundary is illegal (e.g., if it\nis empty after all trailing whitespace has been removed).\n\nmultipartboundary\nLike \"boundary()\", except that this will also return the empty string if the message is not\na multipart message. In other words, there's an automatic sanity check.\n\ntype\nTry real hard to determine the content type (e.g., \"text/plain\", \"image/gif\",\n\"x-weird-type\", which is returned in all-lowercase.\n\nA happy thing: the following code will work just as you would want, even if there's no\nsubtype (as in \"x-weird-type\")... in such a case, the $subtype would simply be the empty\nstring:\n\n($type, $subtype) = split('/', $head->mimetype);\n\nIf the content-type information is missing, it defaults to \"text/plain\", as per RFC 2045:\n\nDefault RFC 2822 messages are typed by this protocol as plain text in\nthe US-ASCII character set, which can be explicitly specified as\n\"Content-type: text/plain; charset=us-ascii\".  If no Content-Type is\nspecified, this default is assumed.\n\nNote: under the \"be liberal in what we accept\" principle, this routine no longer\nsyntax-checks the content type. If it ain't empty, just downcase and return it.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Since nearly all (if not all) parameters must have non-empty values to be considered valid, we\njust return the empty string to signify missing fields. If you need to get the *real* underlying\nvalue, use the inherited \"param()\" method (which returns undef if the parameter is missing).\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "MIME::Field::ParamVal, Mail::Field\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Eryq (eryq@zeegee.com), ZeeGee Software Inc (http://www.zeegee.com). Dianne Skoll\n(dfs@roaringpenguin.com) http://www.roaringpenguin.com\n",
            "subsections": []
        }
    },
    "summary": "MIME::Field::ContType - a \"Content-type\" field",
    "flags": [],
    "examples": [],
    "see_also": []
}