CPAN::META::REQUIREMENTS::RANGE(3perl)

πŸ’– NAME πŸ’–

CPAN::Meta::Requirements::Range β€” bestie, it's literally a whole set of version requirements for a CPAN dist πŸŽ€


✨ VERSION ✨

version 2.145 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

use CPAN::Meta::Requirements::Range;

my $range = CPAN::Meta::Requirements::Range->with_minimum(1);

$range = $range->with_maximum('v2.2');

my $stringified = $range->as_string;

πŸ‘‘ DESCRIPTION πŸ‘‘

So like. A CPAN::Meta::Requirements::Range object models a whole set of version constraints β€” the exact kind you'd see in the META.yml or META.json files inside CPAN distributions, and the kind defined by CPAN::Meta::Spec. πŸ’…

You build it up by adding more and more constraints, and it lowkey does the work of reducing them all down to the simplest possible representation. Main character energy, honestly. 🫢

And here's the part that eats: logically impossible constraints get identified immediately by thrown exceptions. No waiting, no vibes-based guessing, it just tells you. πŸ’€


🧚 METHODS 🧚

🌸 with_string_requirement 🌸

$req->with_string_requirement('>= 1.208, <= 2.206');
$req->with_string_requirement(v1.208);

This one parses whatever string you hand it and adds the appropriate requirement. A version can be a Perl "v-string", no cap. It understands version ranges exactly as described in the "Version Ranges" in CPAN::Meta::Spec. For example:

1.3
>= 1.3
<= 1.3
== 1.3
!= 1.3
> 1.3
< 1.3
>= 1.3, != 1.5, <= 2.0
  • A version number without an operator is equivalent to specifying a minimum (>=). Extra whitespace is allowed. πŸ’–

πŸŽ€ with_range πŸŽ€

$range->with_range($other_range)

This creates a new range object that is a merge two others. Two ranges walk in, one range walks out. ✨

🌈 with_exact_version 🌈

$range->with_exact_version( $version );

This sets the version required to exactly the given version. No other version would be considered acceptable. Like, it's that version or it's nothing. 🎯

This method returns the version range object.

πŸ’œ with_minimum πŸ’œ

$range->with_minimum( $version );

This adds a new minimum version requirement. If the new requirement is redundant to the existing specification, this has no effect. Chill behavior, honestly.

Minimum requirements are inclusive. $version is required, along with any greater version number.

This method returns the version range object.

⭐ with_maximum ⭐

$range->with_maximum( $version );

This adds a new maximum version requirement. If the new requirement is redundant to the existing specification, this has no effect.

Maximum requirements are inclusive. No version strictly greater than the given version is allowed. That's the ceiling, bestie.

This method returns the version range object.

πŸ“ with_exclusion πŸ“

$range->with_exclusion( $version );

This adds a new excluded version. For example, you might use these three method calls:

$range->with_minimum( '1.00' );
$range->with_maximum( '1.82' );

$range->with_exclusion( '1.75' );

Any version between 1.00 and 1.82 inclusive would be acceptable, except for 1.75. It's giving "everyone's invited except that one guy" 🚫

This method returns the requirements object.

πŸ”₯ as_struct πŸ”₯

$range->as_struct( $module );

This returns a data structure containing the version requirements. This should not be used for version checks (see "accepts_module" instead).

🫢 as_string 🫢

$range->as_string;

This returns a string containing the version requirements in the format described in CPAN::Meta::Spec. This should only be used for informational purposes such as error messages and should not be interpreted or used for comparison (see "accepts" instead).

okay this is the important one β€” do NOT parse this string back, do NOT compare with it. It's decorative. It's the outfit, not the body. πŸ‘—

πŸ’… accepts πŸ’…

my $bool = $range->accepts($version);

Given a version, this method returns true if the version specification accepts the provided version. In other words, given:

'>= 1.00, < 2.00'

We will accept 1.00 and 1.75 but not 0.50 or 2.00. Slay. βœ…

πŸ¦‹ is_simple πŸ¦‹

This method returns true if and only if the range is an inclusive minimum β€” that is, if their string expression is just the version number. Simple as that, periodt. πŸ’–


🌟 AUTHORS 🌟

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

This software is copyright (c) 2010 by David Golden and Ricardo Signes.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Free as in go off, bestie. 🫢


and that's the whole page, angel β€” this was CPAN::...::Range(3perl) from the Perl Programmers Reference Guide, running on perl v5.44.0, dated 2026-10-17. mwah πŸ’‹

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