CPAN::META::CONVERTER(3perl)

πŸ’– CPAN::Meta::Converter β€” bestie edition πŸ’–

okay so. this is CPAN::Meta::Converter, from the Perl Programmers Reference Guide, and it does one thing and does it beautifully: it converts CPAN distribution metadata structures. glow-up for your metadata files fr fr ✨


✨ VERSION ✨

version 2.150013 β€” yes she has a version number, she's That Girl πŸŽ€


🌸 SYNOPSIS 🌸

like, here's the whole vibe in four lines, no cap:

my $struct = decode_json_file('META.json');

my $cmc = CPAN::Meta::Converter->new( $struct );

my $new_struct = $cmc->convert( version => "2" );

see how easy that was?? iconic behavior πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically this module converts CPAN Meta structures from one form into another. the main character use case is taking older structures and converting them to the most modern version of the spec β€” but other transformations may be implemented in the future as needed. (e.g. stripping all custom fields, or stripping all optional fields.) lowkey she's flexible, highkey she's just getting started 🌈


πŸ‘‘ METHODS πŸ‘‘

πŸ“ new

my $cmc = CPAN::Meta::Converter->new( $struct );

the constructor should be passed a valid metadata structure, but here's the tea β€” invalid structures are accepted anyway. she's not gonna gatekeep 🫢 if no meta-spec version is provided, version 1.0 will be assumed.

optionally, you can hand her a default_version argument after $struct, like so:

my $cmc = CPAN::Meta::Converter->new( $struct, default_version => "1.4" );

this is only needed when you're converting a metadata fragment that does not include a "meta-spec" field. iykyk πŸ’œ

πŸ’« convert

my $new_struct = $cmc->convert( version => "2" );

returns a new hash reference with the metadata converted to a different form. heads up bestie: convert will die if any conversion/standardization still results in an invalid structure. she does not play 😭

valid parameters include:

  • "version" β€” indicates the desired specification version (e.g. "1.0", "1.1" ... "1.4", "2"). defaults to the latest version of the CPAN Meta Spec.

conversion proceeds through each version in turn. for example, a version 1.2 structure might be converted to 1.3, then 1.4, then finally to version 2. it's giving ✨pipeline✨. the conversion process attempts to clean-up simple errors and standardize data. for example, if "author" is given as a scalar, it will be converted to an array reference containing the item. (and converting a structure to its own version will also clean-up and standardize β€” self-care era πŸ’–)

when data are cleaned and standardized, missing or invalid fields will be replaced with sensible defaults when possible. plot twist: this may be lossy or imprecise. πŸ™ˆ for example, some badly structured META.yml files on CPAN have prerequisite modules listed as both keys and values:

requires => { 'Foo::Bar' => 'Bam::Baz' }

these would be split and each converted to a prerequisite with a minimum version of zero. problem solved, slay πŸ’…

when some mandatory fields are missing or invalid, the conversion will attempt to provide a sensible default, or will fill them with a value of 'unknown'. for example, a missing or unrecognized "license" field will result in a "license" field of 'unknown'. fields that may get an 'unknown' include:

  • abstract
  • author
  • license

she's doing her best, okay πŸ₯Ί

🧚 upgrade_fragment

my $new_struct = $cmc->upgrade_fragment;

returns a new hash reference with the metadata converted to the latest version of the CPAN Meta Spec. no validation is done on the result β€” you must validate after merging fragments into a complete metadata document. that part is on you, bestie, not her πŸ™

available since version 2.141170.


πŸ’€ BUGS πŸ’€

please report any bugs or feature using the CPAN Request Tracker. bugs can be submitted through the web interface at <http://rt.cpan.org/Dist/Display.html?Queue=CPAN-Meta>

when submitting a bug or request, please include a test-file, or a patch to an existing test-file, that illustrates the bug or the desired feature. receipts, basically πŸŽ€


🌟 AUTHORS 🌟

  • David Golden <dagolden@cpan.org>
  • Ricardo Signes <cpan@semiotic.systems>
  • Adam Kennedy <adamk@cpan.org>

three absolute legends. ate and left no crumbs πŸ‘‘


this software is copyright (c) 2010 by David Golden, Ricardo Signes, Adam Kennedy and Contributors.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so go off, legally πŸ’œ


and that's the whole page!! perl v5.44.0, dated 2026-10-17 β€” that's the version-and-date tea from the footer, mwah πŸ’‹ bye bestie, go convert something iconic βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms