{
    "mode": "perldoc",
    "parameter": "CPAN::Meta",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/CPAN%3A%3AMeta/json",
    "generated": "2026-06-03T11:53:27Z",
    "synopsis": "use v5.10;\nuse strict;\nuse warnings;\nuse CPAN::Meta;\nuse Module::Load;\nmy $meta = CPAN::Meta->loadfile('META.json');\nprintf \"testing requirements for %s version %s\\n\",\n$meta->name,\n$meta->version;\nmy $prereqs = $meta->effectiveprereqs;\nfor my $phase ( qw/configure runtime build test/ ) {\nsay \"Requirements for $phase:\";\nmy $reqs = $prereqs->requirementsfor($phase, \"requires\");\nfor my $module ( sort $reqs->requiredmodules ) {\nmy $status;\nif ( eval { load $module unless $module eq 'perl'; 1 } ) {\nmy $version = $module eq 'perl' ? $] : $module->VERSION;\n$status = $reqs->acceptsmodule($module, $version)\n? \"$version ok\" : \"$version not ok\";\n} else {\n$status = \"missing\"\n};\nsay \"  $module ($status)\";\n}\n}",
    "sections": {
        "NAME": {
            "content": "CPAN::Meta - the distribution metadata for a CPAN dist\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 2.150010\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use v5.10;\nuse strict;\nuse warnings;\nuse CPAN::Meta;\nuse Module::Load;\n\nmy $meta = CPAN::Meta->loadfile('META.json');\n\nprintf \"testing requirements for %s version %s\\n\",\n$meta->name,\n$meta->version;\n\nmy $prereqs = $meta->effectiveprereqs;\n\nfor my $phase ( qw/configure runtime build test/ ) {\nsay \"Requirements for $phase:\";\nmy $reqs = $prereqs->requirementsfor($phase, \"requires\");\nfor my $module ( sort $reqs->requiredmodules ) {\nmy $status;\nif ( eval { load $module unless $module eq 'perl'; 1 } ) {\nmy $version = $module eq 'perl' ? $] : $module->VERSION;\n$status = $reqs->acceptsmodule($module, $version)\n? \"$version ok\" : \"$version not ok\";\n} else {\n$status = \"missing\"\n};\nsay \"  $module ($status)\";\n}\n}\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Software distributions released to the CPAN include a META.json or, for older distributions,\nMETA.yml, which describes the distribution, its contents, and the requirements for building and\ninstalling the distribution. The data structure stored in the META.json file is described in\nCPAN::Meta::Spec.\n\nCPAN::Meta provides a simple class to represent this distribution metadata (or *distmeta*),\nalong with some helpful methods for interrogating that data.\n\nThe documentation below is only for the methods of the CPAN::Meta object. For information on the\nmeaning of individual fields, consult the spec.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new\nmy $meta = CPAN::Meta->new($distmetastruct, \\%options);\n\nReturns a valid CPAN::Meta object or dies if the supplied metadata hash reference fails to\nvalidate. Older-format metadata will be up-converted to version 2 if they validate against the\noriginal stated specification.\n\nIt takes an optional hashref of options. Valid options include:\n\n*   lazyvalidation -- if true, new will attempt to convert the given metadata to version 2\nbefore attempting to validate it. This means than any fixable errors will be handled by\nCPAN::Meta::Converter before validation. (Note that this might result in invalid optional\ndata being silently dropped.) The default is false.\n\ncreate\nmy $meta = CPAN::Meta->create($distmetastruct, \\%options);\n\nThis is same as \"new()\", except that \"generatedby\" and \"meta-spec\" fields will be generated if\nnot provided. This means the metadata structure is assumed to otherwise follow the latest\nCPAN::Meta::Spec.\n\nloadfile\nmy $meta = CPAN::Meta->loadfile($distmetafile, \\%options);\n\nGiven a pathname to a file containing metadata, this deserializes the file according to its file\nsuffix and constructs a new \"CPAN::Meta\" object, just like \"new()\". It will die if the\ndeserialized version fails to validate against its stated specification version.\n\nIt takes the same options as \"new()\" but \"lazyvalidation\" defaults to true.\n\nloadyamlstring\nmy $meta = CPAN::Meta->loadyamlstring($yaml, \\%options);\n\nThis method returns a new CPAN::Meta object using the first document in the given YAML string.\nIn other respects it is identical to \"loadfile()\".\n\nloadjsonstring\nmy $meta = CPAN::Meta->loadjsonstring($json, \\%options);\n\nThis method returns a new CPAN::Meta object using the structure represented by the given JSON\nstring. In other respects it is identical to \"loadfile()\".\n\nloadstring\nmy $meta = CPAN::Meta->loadstring($string, \\%options);\n\nIf you don't know if a string contains YAML or JSON, this method will use Parse::CPAN::Meta to\nguess. In other respects it is identical to \"loadfile()\".\n\nsave\n$meta->save($distmetafile, \\%options);\n\nSerializes the object as JSON and writes it to the given file. The only valid option is\n\"version\", which defaults to '2'. On Perl 5.8.1 or later, the file is saved with UTF-8 encoding.\n\nFor \"version\" 2 (or higher), the filename should end in '.json'. JSON::PP is the default JSON\nbackend. Using another JSON backend requires JSON 2.5 or later and you must set the\n$ENV{PERLJSONBACKEND} to a supported alternate backend like JSON::XS.\n\nFor \"version\" less than 2, the filename should end in '.yml'. CPAN::Meta::Converter is used to\ngenerate an older metadata structure, which is serialized to YAML. CPAN::Meta::YAML is the\ndefault YAML backend. You may set the $ENV{PERLYAMLBACKEND} to a supported alternative\nbackend, though this is not recommended due to subtle incompatibilities between YAML parsers on\nCPAN.\n\nmetaspecversion\nThis method returns the version part of the \"metaspec\" entry in the distmeta structure. It is\nequivalent to:\n\n$meta->metaspec->{version};\n\neffectiveprereqs\nmy $prereqs = $meta->effectiveprereqs;\n\nmy $prereqs = $meta->effectiveprereqs( \\@featureidentifiers );\n\nThis method returns a CPAN::Meta::Prereqs object describing all the prereqs for the\ndistribution. If an arrayref of feature identifiers is given, the prereqs for the identified\nfeatures are merged together with the distribution's core prereqs before the CPAN::Meta::Prereqs\nobject is returned.\n\nshouldindexfile\n... if $meta->shouldindexfile( $filename );\n\nThis method returns true if the given file should be indexed. It decides this by checking the\n\"file\" and \"directory\" keys in the \"noindex\" property of the distmeta structure. Note that\nneither the version format nor \"releasestatus\" are considered.\n\n$filename should be given in unix format.\n\nshouldindexpackage\n... if $meta->shouldindexpackage( $package );\n\nThis method returns true if the given package should be indexed. It decides this by checking the\n\"package\" and \"namespace\" keys in the \"noindex\" property of the distmeta structure. Note that\nneither the version format nor \"releasestatus\" are considered.\n\nfeatures\nmy @featureobjects = $meta->features;\n\nThis method returns a list of CPAN::Meta::Feature objects, one for each optional feature\ndescribed by the distribution's metadata.\n\nfeature\nmy $featureobject = $meta->feature( $identifier );\n\nThis method returns a CPAN::Meta::Feature object for the optional feature with the given\nidentifier. If no feature with that identifier exists, an exception will be raised.\n\nasstruct\nmy $copy = $meta->asstruct( \\%options );\n\nThis method returns a deep copy of the object's metadata as an unblessed hash reference. It\ntakes an optional hashref of options. If the hashref contains a \"version\" argument, the copied\nmetadata will be converted to the version of the specification and returned. For example:\n\nmy $oldspec = $meta->asstruct( {version => \"1.4\"} );\n\nasstring\nmy $string = $meta->asstring( \\%options );\n\nThis method returns a serialized copy of the object's metadata as a character string. (The\nstrings are not UTF-8 encoded.) It takes an optional hashref of options. If the hashref contains\na \"version\" argument, the copied metadata will be converted to the version of the specification\nand returned. For example:\n\nmy $string = $meta->asstring( {version => \"1.4\"} );\n\nFor \"version\" greater than or equal to 2, the string will be serialized as JSON. For \"version\"\nless than 2, the string will be serialized as YAML. In both cases, the same rules are followed\nas in the \"save()\" method for choosing a serialization backend.\n\nThe serialized structure will include a \"xserializationbackend\" entry giving the package and\nversion used to serialize. Any existing key in the given $meta object will be clobbered.\n",
            "subsections": []
        },
        "STRING DATA": {
            "content": "The following methods return a single value, which is the value for the corresponding entry in\nthe distmeta structure. Values should be either undef or strings.\n\n*   abstract\n\n*   description\n\n*   dynamicconfig\n\n*   generatedby\n\n*   name\n\n*   releasestatus\n\n*   version\n",
            "subsections": []
        },
        "LIST DATA": {
            "content": "These methods return lists of string values, which might be represented in the distmeta\nstructure as arrayrefs or scalars:\n\n*   authors\n\n*   keywords\n\n*   licenses\n\nThe \"authors\" and \"licenses\" methods may also be called as \"author\" and \"license\", respectively,\nto match the field name in the distmeta structure.\n",
            "subsections": []
        },
        "MAP DATA": {
            "content": "These readers return hashrefs of arbitrary unblessed data structures, each described more fully\nin the specification:\n\n*   metaspec\n\n*   resources\n\n*   provides\n\n*   noindex\n\n*   prereqs\n\n*   optionalfeatures\n",
            "subsections": []
        },
        "CUSTOM DATA": {
            "content": "A list of custom keys are available from the \"customkeys\" method and particular keys may be\nretrieved with the \"custom\" method.\n\nsay $meta->custom($) for $meta->customkeys;\n\nIf a custom key refers to a data structure, a deep clone is returned.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Please report any bugs or feature using the CPAN Request Tracker. Bugs can be submitted through\nthe web interface at <http://rt.cpan.org/Dist/Display.html?Queue=CPAN-Meta>\n\nWhen submitting a bug or request, please include a test-file or a patch to an existing test-file\nthat illustrates the bug or desired feature.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "*   CPAN::Meta::Converter\n\n*   CPAN::Meta::Validator\n",
            "subsections": []
        },
        "SUPPORT": {
            "content": "Bugs / Feature Requests\nPlease report any bugs or feature requests through the issue tracker at\n<https://github.com/Perl-Toolchain-Gang/CPAN-Meta/issues>. You will be notified automatically of\nany progress on your issue.\n",
            "subsections": [
                {
                    "name": "Source Code",
                    "content": "This is open source software. The code repository is available for public review and\ncontribution under the terms of the license.\n\n<https://github.com/Perl-Toolchain-Gang/CPAN-Meta>\n\ngit clone https://github.com/Perl-Toolchain-Gang/CPAN-Meta.git\n"
                }
            ]
        },
        "AUTHORS": {
            "content": "*   David Golden <dagolden@cpan.org>\n\n*   Ricardo Signes <rjbs@cpan.org>\n\n*   Adam Kennedy <adamk@cpan.org>\n",
            "subsections": []
        },
        "CONTRIBUTORS": {
            "content": "*   Ansgar Burchardt <ansgar@cpan.org>\n\n*   Avar Arnfjord Bjarmason <avar@cpan.org>\n\n*   Benjamin Noggle <agwind@users.noreply.github.com>\n\n*   Christopher J. Madsen <cjm@cpan.org>\n\n*   Chuck Adams <cja987@gmail.com>\n\n*   Cory G Watson <gphat@cpan.org>\n\n*   Damyan Ivanov <dam@cpan.org>\n\n*   David Golden <xdg@xdg.me>\n\n*   Eric Wilhelm <ewilhelm@cpan.org>\n\n*   Graham Knop <haarg@haarg.org>\n\n*   Gregor Hermann <gregoa@debian.org>\n\n*   Karen Etheridge <ether@cpan.org>\n\n*   Kenichi Ishigaki <ishigaki@cpan.org>\n\n*   Kent Fredric <kentfredric@gmail.com>\n\n*   Ken Williams <kwilliams@cpan.org>\n\n*   Lars Dieckow <daxim@cpan.org>\n\n*   Leon Timmermans <leont@cpan.org>\n\n*   majensen <maj@fortinbras.us>\n\n*   Mark Fowler <markf@cpan.org>\n\n*   Matt S Trout <mst@shadowcat.co.uk>\n\n*   Michael G. Schwern <mschwern@cpan.org>\n\n*   Mohammad S Anwar <mohammad.anwar@yahoo.com>\n\n*   mohawk2 <mohawk2@users.noreply.github.com>\n\n*   moznion <moznion@gmail.com>\n\n*   Niko Tyni <ntyni@debian.org>\n\n*   Olaf Alders <olaf@wundersolutions.com>\n\n*   Olivier Mengué <dolmen@cpan.org>\n\n*   Randy Sims <randys@thepierianspring.org>\n\n*   Tomohiro Hosaka <bokutin@bokut.in>\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": "CPAN::Meta - the distribution metadata for a CPAN dist",
    "flags": [],
    "examples": [],
    "see_also": []
}