Env::Assert - Ensure that the environment variables match what you need, or abort.
version 0.006
use Env::Assert qw( assert ); my %want = ( options => { exact => 1, }, variables => { USER => { regexp => '^[[:word:]]{1}$', required => 1 }, }, ); my %parameters; $parameters{'break_at_first_error'} = 1; my $r = assert( \%ENV, $desc, \%parameters ); if( ! $r->{'success'} ) { say report_errors( $r->{'errors'} ); }
Package Env::Assert is currently being developed so changes in the API are possible, though not likely.
No external dependencies outside Perl's standard distribution.
No functions are automatically exported to the calling namespace.
Ensure your environment, parameter env (hashref), matches with the environment description, parameter want (hashref). Use parameter params (hashref) to specify processing options.
Supported params:
Verify environment only up until the first error. Then break and return with only that error.
Return: hashref: { success => 1/0, errors => hashref, };
Report errors in a nicely formatted way.
Extract an environment description from a .envdesc file.
Mikko Koivunalho <mikkoi@cpan.org>
This software is copyright (c) 2023 by Mikko Koivunalho.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Env::Assert, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Env::Assert
CPAN shell
perl -MCPAN -e shell install Env::Assert
For more information on module installation, please visit the detailed CPAN module installation guide.