CPAN::META::REQUIREMENTS::RANGE(3pm)
π CPAN::Meta::Requirements::Range(3pm) β a whole vibe of version rules β¨
Okay so bestie, welcome to the CPAN::Meta::Requirements::Range page from the Perl Programmers Reference Guide β yes it's a mouthful, but it's also kinda iconic ngl. It's the manual page for a little object that holds version requirements for a CPAN dist. Periodt. πΈ
β¨ NAME β¨
CPAN::Meta::Requirements::Range β literally just a set of version requirements for a CPAN dist. That's the whole thing. π
π¦ VERSION π¦
version 2.143 β this is the one, no cap.
π SYNOPSIS π
Here's the vibe check in code form, run this and slay:
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;
Look at her go. π
π DESCRIPTION π
So a CPAN::Meta::Requirements::Range object models a set of version constraints β like, exactly the kind you'd see specified in the META.yml or META.json files in CPAN distributions, and as defined by CPAN::Meta::Spec. The way this works is you just keep building it up: add more and more constraints, and it'll reduce them down to the simplest possible representation. It's giving minimalism. π§
And the best part? If you hand it constraints that are logically impossible, it identifies them immediately by throwing exceptions. Not me getting rejected in real time π β but that's actually what you want, fr fr.
π METHODS π
πΈ with_string_requirement
$req->with_string_requirement('>= 1.208, <= 2.206');
$req->with_string_requirement(v1.208);
This method parses the passed-in string and adds the appropriate requirement. And yes, a version can be a Perl "v-string" β she's flexible like that. π
It understands version ranges 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 β she's not gonna fight you over a couple of spaces, that's lowkey chill of her. β¨
π«Ά with_range
$range->with_range($other_range)
This creates a new range object that is a merge of two others. Two ranges become one, it's giving friendship bracelet energy. π
π 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. It's giving "this or nothing" main character energy β no wiggle room, no compromises, absolutely zero. π
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 β it just politely does nothing, which is so mature of it.
Minimum requirements are inclusive. So $version is required, along with any greater version number. She said "this and up, no exceptions bestie." π
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 β same chill energy as above.
Maximum requirements are inclusive. No version strictly greater than the given version is allowed. So the ceiling is real, but you're allowed to touch it. π
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' );
So any version between 1.00 and 1.82 inclusive would be acceptable β except for 1.75. It's giving blocked. π Not 1.75 specifically catching strays but okay, we've all been there.
This method returns the requirements object.
π as_struct
$range->as_struct( $module );
This returns a data structure containing the version requirements. Lowkey important though: this should not be used for version checks β see accepts_module instead. Don't do it bestie, that's not what she's for. π«Ά
π
as_string
$range->as_string;
This returns a string containing the version requirements in the format described in CPAN::Meta::Spec. But listen: this should only be used for informational purposes β like error messages β and should not be interpreted or used for comparison. See accepts instead, that's the one that actually does the work. β¨
π₯ 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. It's a whole vibe check and some versions are simply not passing it. π
π 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, clean, unbothered. The way she just is. β¨
π AUTHORS π
- David Golden
<dagolden@cpan.org> - Ricardo Signes
<rjbs@cpan.org>
Legend behaviour, both of them. π
πΈ COPYRIGHT AND LICENSE πΈ
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 software, free spirit, we love to see it. π«Ά
Alright bestie, that's the whole page β every method, every caveat, no skips, we ate and left no crumbs. πβ¨
π perl v5.42.3 Β· 2026-11-03 Β· CPAN::Meta::Requirements::Range(3pm) π
Byeee, go write some requirements that actually accept the right versions π π
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms