{
    "mode": "perldoc",
    "parameter": "Parse::CPAN::Meta",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Parse%3A%3ACPAN%3A%3AMeta/json",
    "generated": "2026-06-03T01:26:41Z",
    "synopsis": "#############################################\n# In your file\n---\nname: My-Distribution\nversion: 1.23\nresources:\nhomepage: \"http://example.com/dist/My-Distribution\"\n#############################################\n# In your program\nuse Parse::CPAN::Meta;\nmy $distmeta = Parse::CPAN::Meta->loadfile('META.yml');\n# Reading properties\nmy $name     = $distmeta->{name};\nmy $version  = $distmeta->{version};\nmy $homepage = $distmeta->{resources}{homepage};",
    "sections": {
        "NAME": {
            "content": "Parse::CPAN::Meta - Parse META.yml and META.json CPAN metadata files\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 2.150010\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "#############################################\n# In your file\n\n---\nname: My-Distribution\nversion: 1.23\nresources:\nhomepage: \"http://example.com/dist/My-Distribution\"\n\n\n#############################################\n# In your program\n\nuse Parse::CPAN::Meta;\n\nmy $distmeta = Parse::CPAN::Meta->loadfile('META.yml');\n\n# Reading properties\nmy $name     = $distmeta->{name};\nmy $version  = $distmeta->{version};\nmy $homepage = $distmeta->{resources}{homepage};\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Parse::CPAN::Meta is a parser for META.json and META.yml files, using JSON::PP and/or\nCPAN::Meta::YAML.\n\nParse::CPAN::Meta provides three methods: \"loadfile\", \"loadjsonstring\", and\n\"loadyamlstring\". These will read and deserialize CPAN metafiles, and are described below in\ndetail.\n\nParse::CPAN::Meta provides a legacy API of only two functions, based on the YAML functions of\nthe same name. Wherever possible, identical calling semantics are used. These may only be used\nwith YAML sources.\n\nAll error reporting is done with exceptions (die'ing).\n\nNote that META files are expected to be in UTF-8 encoding, only. When converted string data, it\nmust first be decoded from UTF-8.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "loadfile\nmy $metadatastructure = Parse::CPAN::Meta->loadfile('META.json');\n\nmy $metadatastructure = Parse::CPAN::Meta->loadfile('META.yml');\n\nThis method will read the named file and deserialize it to a data structure, determining whether\nit should be JSON or YAML based on the filename. The file will be read using the \":utf8\" IO\nlayer.\n\nloadyamlstring\nmy $metadatastructure = Parse::CPAN::Meta->loadyamlstring($yamlstring);\n\nThis method deserializes the given string of YAML and returns the first document in it. (CPAN\nmetadata files should always have only one document.) If the source was UTF-8 encoded, the\nstring must be decoded before calling \"loadyamlstring\".\n\nloadjsonstring\nmy $metadatastructure = Parse::CPAN::Meta->loadjsonstring($jsonstring);\n\nThis method deserializes the given string of JSON and the result. If the source was UTF-8\nencoded, the string must be decoded before calling \"loadjsonstring\".\n\nloadstring\nmy $metadatastructure = Parse::CPAN::Meta->loadstring($somestring);\n\nIf you don't know whether a string contains YAML or JSON data, this method will use some\nheuristics and guess. If it can't tell, it assumes YAML.\n\nyamlbackend\nmy $backend = Parse::CPAN::Meta->yamlbackend;\n\nReturns the module name of the YAML serializer. See \"ENVIRONMENT\" for details.\n\njsonbackend\nmy $backend = Parse::CPAN::Meta->jsonbackend;\n\nReturns the module name of the JSON serializer. If \"CPANMETAJSONBACKEND\" is set, this will be\nwhatever that's set to. If not, this will either be JSON::PP or JSON. If \"PERLJSONBACKEND\" is\nset, this will return JSON as further delegation is handled by the JSON module. See\n\"ENVIRONMENT\" for details.\n\njsondecoder\nmy $decoder = Parse::CPAN::Meta->jsondecoder;\n\nReturns the module name of the JSON decoder. Unlike \"jsonbackend\", this is not necessarily a\nfull JSON-style module, but only something that will provide a \"decodejson\" subroutine. If\n\"CPANMETAJSONDECODER\" is set, this will be whatever that's set to. If not, this will be\nwhatever has been selected as \"jsonbackend\". See \"ENVIRONMENT\" for more notes.\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "For maintenance clarity, no functions are exported by default. These functions are available for\nbackwards compatibility only and are best avoided in favor of \"loadfile\".\n",
            "subsections": [
                {
                    "name": "Load",
                    "content": "my @yaml = Parse::CPAN::Meta::Load( $string );\n\nParses a string containing a valid YAML stream into a list of Perl data structures.\n"
                },
                {
                    "name": "LoadFile",
                    "content": "my @yaml = Parse::CPAN::Meta::LoadFile( 'META.yml' );\n\nReads the YAML stream from a file instead of a string.\n"
                }
            ]
        },
        "ENVIRONMENT": {
            "content": "CPANMETAJSONDECODER\nBy default, JSON::PP will be used for deserializing JSON data. If the \"CPANMETAJSONDECODER\"\nenvironment variable exists, this is expected to be the name of a loadable module that provides\na \"decodejson\" subroutine, which will then be used for deserialization. Relying only on the\nexistence of said subroutine allows for maximum compatibility, since this API is provided by all\nof JSON::PP, JSON::XS, Cpanel::JSON::XS, JSON::MaybeXS, JSON::Tiny, and Mojo::JSON.\n\nCPANMETAJSONBACKEND\nBy default, JSON::PP will be used for deserializing JSON data. If the \"CPANMETAJSONBACKEND\"\nenvironment variable exists, this is expected to be the name of a loadable module that provides\nthe JSON API, since downstream code expects to be able to call \"new\" on this class. As such,\nwhile JSON::PP, JSON::XS, Cpanel::JSON::XS and JSON::MaybeXS will work for this, to use\nMojo::JSON or JSON::Tiny for decoding requires setting \"CPANMETAJSONDECODER\".\n\nPERLJSONBACKEND\nIf the \"CPANMETAJSONBACKEND\" environment variable does not exist, and if \"PERLJSONBACKEND\"\nenvironment variable exists, is true and is not \"JSON::PP\", then the JSON module (version 2.5 or\ngreater) will be loaded and used to interpret \"PERLJSONBACKEND\". If JSON is not installed or\nis too old, an exception will be thrown. Note that at the time of writing, the only useful\nvalues are 1, which will tell JSON to guess, or JSON::XS - if you want to use a newer JSON\nmodule, see \"CPANMETAJSONBACKEND\".\n\nPERLYAMLBACKEND\nBy default, CPAN::Meta::YAML will be used for deserializing YAML data. If the\n\"PERLYAMLBACKEND\" environment variable is defined, then it is interpreted as a module to use\nfor deserialization. The given module must be installed, must load correctly and must implement\nthe \"Load()\" function or an exception will be thrown.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "*   David Golden <dagolden@cpan.org>\n\n*   Ricardo Signes <rjbs@cpan.org>\n\n*   Adam Kennedy <adamk@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is copyright (c) 2010 by David Golden, Ricardo Signes, Adam Kennedy and\nContributors.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        }
    },
    "summary": "Parse::CPAN::Meta - Parse META.yml and META.json CPAN metadata files",
    "flags": [],
    "examples": [],
    "see_also": []
}