{
    "mode": "perldoc",
    "parameter": "MIME::Type",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/MIME%3A%3AType/json",
    "generated": "2026-06-11T08:32:42Z",
    "synopsis": "use MIME::Types;\nmy $mimetypes = MIME::Types->new;\nmy MIME::Type $plaintext = $mimetypes->type('text/plain');\nprint $plaintext->mediaType;   # text\nprint $plaintext->subType;     # plain\nmy @ext = $plaintext->extensions;\nprint \"@ext\"                   # txt asc c cc h hh cpp\nprint $plaintext->encoding     # 8bit\nif($plaintext->isBinary)       # false\nif($plaintext->isAscii)        # true\nif($plaintext->equals('text/plain') {...}\nif($plaintext eq 'text/plain') # same\nprint MIME::Type->simplified('x-appl/x-zip') #  'appl/zip'",
    "sections": {
        "NAME": {
            "content": "MIME::Type - description of one MIME type\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use MIME::Types;\nmy $mimetypes = MIME::Types->new;\nmy MIME::Type $plaintext = $mimetypes->type('text/plain');\nprint $plaintext->mediaType;   # text\nprint $plaintext->subType;     # plain\n\nmy @ext = $plaintext->extensions;\nprint \"@ext\"                   # txt asc c cc h hh cpp\n\nprint $plaintext->encoding     # 8bit\nif($plaintext->isBinary)       # false\nif($plaintext->isAscii)        # true\nif($plaintext->equals('text/plain') {...}\nif($plaintext eq 'text/plain') # same\n\nprint MIME::Type->simplified('x-appl/x-zip') #  'appl/zip'\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "MIME types are used in MIME entities, for instance as part of e-mail and HTTP traffic. Sometimes\nreal knowledge about a mime-type is need. Objects of \"MIME::Type\" store the information on one\nsuch type.\n",
            "subsections": []
        },
        "OVERLOADED": {
            "content": "overload: string comparison\nWhen a MIME::Type object is compared to either a string or another MIME::Type, the equals()\nmethod is called. Comparison is smart, which means that it extends common string comparison\nwith some features which are defined in the related RFCs.\n\noverload: stringification\nThe stringification (use of the object in a place where a string is required) will result in\nthe type name, the same as type() returns.\n\nexample: use of stringification\n\nmy $mime = MIME::Type->new('text/html');\nprint \"$mime\\n\";   # explicit stringification\nprint $mime;       # implicit stringification\n",
            "subsections": []
        },
        "METHODS": {
            "content": "",
            "subsections": [
                {
                    "name": "Initiation",
                    "content": "MIME::Type->new(%options)\nCreate (*instantiate*) a new MIME::Type object which manages one mime type.\n\n-Option    --Default\nencoding    <depends on type>\nextensions  []\nsimplified  <derived from type>\nsystem      undef\ntype        <required>\n\nencoding => '7bit'|'8bit'|'base64'|'quoted-printable'\nHow must this data be encoded to be transported safely. The default depends on the type:\nmimes with as main type \"text/\" will default to \"quoted-printable\" and all other to\n\"base64\".\n\nextensions => REF-ARRAY\nAn array of extensions which are using this mime.\n\nsimplified => STRING\nThe mime types main- and sub-label can both start with \"x-\", to indicate that is a\nnon-registered name. Of course, after registration this flag can disappear which adds to\nthe confusion. The simplified string has the \"x-\" thingies removed and are translated to\nlower-case.\n\nsystem => REGEX\nRegular expression which defines for which systems this rule is valid. The REGEX is\nmatched on $^O.\n\ntype => STRING\nThe type which is defined here. It consists of a *type* and a *sub-type*, both\ncase-insensitive. This module will return lower-case, but accept upper-case.\n"
                },
                {
                    "name": "Attributes",
                    "content": "$obj->encoding()\nReturns the type of encoding which is required to transport data of this type safely.\n\n$obj->extensions()\nReturns a list of extensions which are known to be used for this mime type.\n\n$obj->simplified( [$string] )\nMIME::Type->simplified( [$string] )\nReturns the simplified mime type for this object or the specified STRING. Mime type names\ncan get officially registered. Until then, they have to carry an \"x-\" preamble to indicate\nthat. Of course, after recognition, the \"x-\" can disappear. In many cases, we prefer the\nsimplified version of the type.\n\nexample: results of simplified()\n\nmy $mime = MIME::Type->new(type => 'x-appl/x-zip');\nprint $mime->simplified;                     # 'appl/zip'\n\nprint $mime->simplified('text/PLAIN');       # 'text/plain'\nprint MIME::Type->simplified('x-xyz/x-abc'); # 'xyz/abc'\n\n$obj->system()\nReturns the regular expression which can be used to determine whether this type is active on\nthe system where you are working on.\n\n$obj->type()\nReturns the long type of this object, for instance 'text/plain'\n"
                },
                {
                    "name": "Knowledge",
                    "content": "$obj->equals($string|$mime)\nCompare this mime-type object with a STRING or other object. In case of a STRING,\nsimplification will take place.\n\n$obj->isAscii()\nOld name for isText().\n\n$obj->isBinary()\nReturns true when the type is not known to be text. See isText().\n\n$obj->isExperimental()\n[2.00] Return \"true\" when the type is defined for experimental use; the subtype starts with\n\"x.\"\n\n$obj->isPersonal()\n[2.00] Return \"true\" when the type is defined by a person for private use; the subtype\nstarts with \"prs.\"\n\n$obj->isRegistered()\nMime-types which are not registered by IANA nor defined in RFCs shall start with an \"x-\".\nThis counts for as well the media-type as the sub-type. In case either one of the types\nstarts with \"x-\" this method will return false.\n\n$obj->isSignature()\nReturns true when the type is in the list of known signatures.\n\n$obj->isText()\n[2.05] All types which may have the charset attribute, are text. However, there is currently\nno record of attributes in this module... so we guess.\n\n$obj->isVendor()\n[2.00] Return \"true\" when the type is defined by a vendor; the subtype starts with \"vnd.\"\n\n$obj->mediaType()\nThe media type of the simplified mime. For 'text/plain' it will return 'text'.\n\nFor historical reasons, the 'mainType' method still can be used to retrieve the same value.\nHowever, that method is deprecated.\n\n$obj->subType()\nThe sub type of the simplified mime. For 'text/plain' it will return 'plain'.\n"
                }
            ]
        },
        "DIAGNOSTICS": {
            "content": "Error: Type parameter is obligatory.\nWhen a MIME::Type object is created, the type itself must be specified with the \"type\"\noption flag.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "This module is part of MIME-Types distribution version 2.22, built on October 27, 2021. Website:\nhttp://perl.overmeer.net/CPAN/\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "Copyrights 1999-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself. See http://dev.perl.org/licenses/\n",
            "subsections": []
        }
    },
    "summary": "MIME::Type - description of one MIME type",
    "flags": [],
    "examples": [],
    "see_also": []
}