CPAN::M...s::Range(3)
Hey bestie! π You're reading CPAN::Meta::Requirements::Range(3) from the User Contributed Perl Documentation β the manual name is CPAN::Meta::Requirements::Range, and it's all about version requirements for a CPAN dist. Buckle up, it's lowkey iconic β¨
π NAME π
CPAN::Meta::Requirements::Range β a set of version requirements for a CPAN dist. Periodt.
πΈ VERSION πΈ
version 2.143
π¦ 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 β¨
A CPAN::Meta::Requirements::Range object models a set of version constraints, like the ones specified in META.yml or META.json files in CPAN distributions, and as defined by CPAN::Meta::Spec. You can build it up by adding more and more constraints, and it will reduce them to the simplest representation.
Logically impossible constraints will be identified immediately by thrown exceptions. No cap, it just throws.
π 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. A version can be a Perl "v-string". 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. π
π« with_range
$range->with_range($other_range)
This creates a new range object that's a merge of two others. Slay.
π 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.
This method returns the version range object. Only one version gets the crown π
π 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.
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.
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.
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). Important lil heads-up, bestie!
π 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).
π 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.
π§ 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.
π AUTHORS π
- David Golden
<dagolden@cpan.org> - Ricardo Signes
<rjbs@cpan.org>
πΈ 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.
That's the whole page, bestie! This lil manual page is served up by perl v5.42.0, dated 2023-06-20, and filed under CPAN::M...s::Range(3) β go forth and slay those version constraints π
π
π¦ where this page comes from
- opensuse-leap 16.0: perl-CPAN-Meta-Requirements 2.143000-160000.2.2 Β· Artistic-1.0 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