CPAN::Requirements::Dynamic(3) User Contributed Perl Documentation CPAN::Requirements::Dynamic(3)

# [SYNOPSIS](#SYNOPSIS)

```
 my $result = $dynamic->evaluate({
   expressions => [
     {
       condition => [ 'has_perl' => 'v5.20.0' ],
       prereqs => { Bar => "1.3" },
     },
     {
       condition => [ is_os => 'linux' ],
       prereqs => { Baz => "1.4" },
     },
     {
       condition => [ config_defined => 'usethreads' ],
       prereqs => { Quz => "1.5" },
     },
     {
       condition => [ and =>
         [ config_defined => 'usethreads' ],
         [ is_os => 'openbsd' ],
       ],
       prereqs => { Euz => "1.7" },
     },
     {
       condition => [ not => is_os_type => 'Unix'],
       error => 'OS unsupported',
     },
   ],
 });
```

# [DESCRIPTION](#DESCRIPTION)

This module implements a format for describing dynamic prerequisites of a distribution.

This constructor takes two (optional but recommended) named arguments

- config
  
  This is an ExtUtils::Config (compatible) object for reading configuration.
- pureperl\_only
  
  This should be the value of the "pureperl-only" flag.

This takes a hash with two named arguments: "version" and "expressions". The former is the version of the format, it currently defaults to 1. The latter is a list of hashes that can contain the following keys:

- condition
  
  The condition of the dynamic requirement. This is an array with a name as first values and zero or more arguments following it. The semantics are described below under "Conditions"
- prereqs
  
  The prereqs is a hash with modules for keys and the required version as values (e.g. "{ Foo =&gt; '1.234' }").
- phase
  
  The phase of the requirements. This defaults to 'runtime'. Other valid values include 'build' and 'test'.
- relation
  
  The relation of the requirements. This defaults to 'requires', but other valid values include 'recommends', 'suggests' and 'conflicts'.
- error
  
  It will die with this error if set. The two messages "No support for OS" and "OS unsupported" have special meaning to CPAN Testers and are generally encouraged for situations that indicate not a failed build but an impossibility to build.

"condition" and one of "prereqs" or "error" are mandatory.

This takes a filename, that can be either a YAML file or a JSON file, and evaluates it.

## [Conditions](#Conditions)

*can\_run($command)*

Returns true if a $command can be run.

*config\_defined($variable)*

This returns true if a specific configuration variable is defined.

*has\_env($variable)*

This returns true if the environmental variable with the name in $variable is true.

*has\_perl($version)*

Returns true if the perl version satisfies $version. $version is interpreted exactly as in the CPAN::Meta spec (e.g. 1.2 equals '&gt;= 1.2').

*is\_extended*

Returns true if extended testing is asked for.

*is\_os(@systems)*

Returns true if the OS name equals any of @systems.

*is\_os\_type($type)*

Returns true if the OS type equals $type. Typical values of $type are 'Unix' or 'Windows'.

*is\_smoker*

Returns true when running on a smoker.

*has\_env*

This returns true if the given environmental variable is true.

*want\_xs*

This returns true if a compiler appears to be available, and the "pureperl\_only" option has not been set.

*not*

This takes an expression and negates its value.

*or*

This takes list of arrayrefs, each containing a condition expression. If at least one of the conditions is true this will also return true.

*and*

This takes a list of arrayrefs, each containing a condition expression. If all of the conditions are true this will also return true.

# [POD ERRORS](#POD_ERRORS)

Hey! **The above document had some coding errors, which are explained below:**

[Around line 170:](#Around)

Unknown directive: =method

[Around line 186:](#Around~2)

Unknown directive: =method

[Around line 216:](#Around~3)

Unknown directive: =method

2026-10-26 perl v5.44.0

---

Document: CPAN::Requirements::Dynamic(3pm) from perl-cpan-requirements-dynamic 0.003-r2 (Chainguard OS)
Source: https://github.com/Leont/cpan-requirements-dynamic
