{
    "mode": "perldoc",
    "parameter": "File::Type::Builder",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/File%3A%3AType%3A%3ABuilder/json",
    "generated": "2026-06-15T14:30:04Z",
    "synopsis": "my $build = File::Type::Builder->new();\nwhile (<magic>) {\nchomp;\nmy $parsed = $build->parsemagic($);\nmy $code   = $build->stringstart($parsed);\n(or stringoffset or beshort)\n}",
    "sections": {
        "NAME": {
            "content": "File::Type::Builder - parse mime-magic and generate code\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "my $build = File::Type::Builder->new();\n\nwhile (<magic>) {\nchomp;\nmy $parsed = $build->parsemagic($);\n\nmy $code   = $build->stringstart($parsed);\n(or stringoffset or beshort)\n}\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Reads in the mime-magic file format and translates it to code. (This documentation would be\nlonger if I really expected anyone other than me to run the code.)\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new\nCreates a new File::Type::Builder object.\n\nparsemagic\nPulls apart a line of a mime-magic file using a string of regular expressions.\n\nAn example mime-magic file can be found in cleancode CVS at\n<http://cleancode.org/cgi-bin/viewcvs.cgi/email/mime-magic.mime?rev=1.1.1.1>\n\nstring\nBuilds code to match magic that's of type string.\n\nHas to do some cleverness to make the regular expression work properly.\n\nbe\nBuilds code to match 'beshort' and 'belong' magic (eg audio/mpeg, image/jpeg).\n",
            "subsections": []
        },
        "PRIVATE METHODS": {
            "content": "substrmatching\nSometimes the data is smaller than the offset we're looking for in the file. If this is the\ncase, then the file is obviously not of that type, and furthermore we should avoid issuing a\ncouple of warnings that Perl would otherwise emit.\n\nThis subroutine generates this code.\n\ngetescapes\nReturns a reference to a hash defining characters that should not be escaped.\n",
            "subsections": []
        },
        "TODO": {
            "content": "* Add handlers for other magic types (bedate, byte, etc)\n\n* Make verbosity/logging nicer.\n\n* Find more edge cases.\n\n* Remove redundant 'if (length $data > 0)' check.\n\nLonger term:\n\n* Fix for multiple magic format types?\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Incomplete. Some known issues with odd entries in mime-magic. Skips some mime-magic lines.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "File::Type, which is partially generated by this module.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Paul Mison <pmison@fotango.com>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2003 Fotango Ltd.\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "Licensed under the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "File::Type::Builder - parse mime-magic and generate code",
    "flags": [],
    "examples": [],
    "see_also": []
}