CPAN::META::PREREQS(3perl)

πŸ’– CPAN::Meta::Prereqs πŸ’–

okay bestie, welcome to CPAN::Meta::Prereqs β€” a whole set of distribution prerequisites, organized by phase and type. that's the whole vibe. ✨

✨ VERSION ✨

version 2.150013 πŸŽ€


🌸 DESCRIPTION 🌸

so a CPAN::Meta::Prereqs object is basically the receipts for what a CPAN distribution needs β€” either for the distribution itself or for one of its optional features. every set of prereqs gets filed under a phase and a type, exactly as described in CPAN::Meta::Prereqs. periodt. πŸ’…


πŸ¦‹ METHODS πŸ¦‹

🌟 new

my $prereq = CPAN::Meta::Prereqs->new( \%prereq_spec );

this one hands you a brand-new set of Prereqs, bestie. the input should look like the contents of the "prereqs" field described in CPAN::Meta::Spec β€” so basically something along the lines of this:

my $prereq = CPAN::Meta::Prereqs->new({
  runtime => {
    requires => {
      'Some::Module' => '1.234',
      ...,
    },
    ...,
  },
  ...,
});

you can also build a completely empty set of prereqs like this:

my $prereqs = CPAN::Meta::Prereqs->new;

and that empty set is so useful β€” it's giving little empty basket energy 🧺✨ β€” you just keep accumulating new prereqs in it and then dump the whole thing into a structure or a string at the end. iconic.

🌟 requirements_for

my $requirements = $prereqs->requirements_for( $phase, $type );

this returns a CPAN::Meta::Requirements object for whatever $phase/$type combo you asked for. if literally nothing is registered for that combo, you get a fresh new CPAN::Meta::Requirements object back, and you're free to add to it as needed. 🫢

if $phase or $type are undefined or invalid in any other way, an exception gets raised. no cap. 😭

🌟 phases

my @phases = $prereqs->phases;

this hands you the list of every phase currently populated in the prereqs object β€” perfect for iterating over, bestie. go off. πŸ”₯

🌟 types_in

my @runtime_types = $prereqs->types_in('runtime');

this gives you the list of every type currently populated in the prereqs object for the phase you passed in. iterating food. πŸ“

🌟 with_merged_prereqs

my $new_prereqs = $prereqs->with_merged_prereqs( $other_prereqs );

my $new_prereqs = $prereqs->with_merged_prereqs( \@other_prereqs );

this returns a new CPAN::Meta::Prereqs object where all those other prereqs you passed in are merged into the current set. it's mainly here so you can combine a distribution's core prereqs with the prereqs of one of its optional features. πŸ‘‘

and the important part: the new prereqs object has no ties to the originals. you can keep altering it and the originals won't feel a thing. πŸ’€

🌟 merged_requirements

my $new_reqs = $prereqs->merged_requirements( \@phases, \@types );
my $new_reqs = $prereqs->merged_requirements( \@phases );
my $new_reqs = $prereqs->merged_requirements();

this one joins together all the requirements across a bunch of phases and types into a brand-new CPAN::Meta::Requirements object. if you omit the arguments entirely, it defaults to "runtime", "build" and "test" for phases, and "requires" and "recommends" for types. the lazy-girl defaults, love that for you. 🌈

🌟 as_string_hash

this method returns a hashref stuffed with structures suitable for dumping into a distmeta data structure. it's made up of hashes and strings only β€” there will be absolutely no Prereqs, CPAN::Meta::Requirements, or "version" objects hiding inside it. squeaky clean. ✨

🌟 is_finalized

returns true if the set of prereqs has been marked "finalized," meaning it cannot be altered. it's locked in. πŸ”’

🌟 finalize

calling finalize on a Prereqs object closes it for any further modification. and if you try to make changes that would actually alter the prereqs?

boom. πŸ’€ an exception gets thrown. do not test her.

🌟 clone

my $cloned_prereqs = $prereqs->clone;

returns a Prereqs object identical to the original, except you can alter the clone without touching the original. oh and finalization does not survive cloning β€” so yes, you may clone a finalized set of prereqs and then go wild modifying the clone. main character loophole energy. πŸ‘‘πŸ’…


πŸ™ˆ BUGS πŸ™ˆ

please report any bugs or feature requests 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 you're submitting a bug or a request, please include a test-file or a patch to an existing test-file that illustrates the bug or the desired feature. we're begging. πŸ₯Ί


πŸ‘‘ AUTHORS πŸ‘‘

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

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.


and that's the whole page, bestie β€” brought to you by perl v5.44.0, dated 2026-10-17, from CPAN::Meta::Prereqs(3perl). slay, go build something. πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ 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