NAME
Venus::Vars - Vars Class
ABSTRACT
Vars Class for Perl 5
SYNOPSIS
package main;
use Venus::Vars;
my $vars = Venus::Vars->new(
value => { USER => 'cpanery', HOME => '/home/cpanery', },
named => { iam => 'USER', root => 'HOME', },
);
# $vars->root; # $ENV{HOME}
# $vars->home; # $ENV{HOME}
# $vars->get('home'); # $ENV{HOME}
# $vars->get('HOME'); # $ENV{HOME}
# $vars->iam; # $ENV{USER}
# $vars->user; # $ENV{USER}
# $vars->get('user'); # $ENV{USER}
# $vars->get('USER'); # $ENV{USER}
DESCRIPTION
This package provides methods for accessing %ENV
items.
ATTRIBUTES
This package has the following attributes:
named
named(HashRef)
This attribute is read-write, accepts (HashRef)
values, is optional, and defaults to {}
.
INHERITS
This package inherits behaviors from:
INTEGRATES
This package integrates behaviors from:
METHODS
This package provides the following methods:
default
default() (HashRef)
The default method returns the default value, i.e. {%ENV}
.
Since 0.01
- default example 1
-
# given: synopsis; my $default = $vars->default; # { USER => 'cpanery', HOME => '/home/cpanery', ... }
exists
exists(Str $key) (Bool)
The exists method takes a name or index and returns truthy if an associated value exists.
Since 0.01
get
get(Str $key) (Any)
The get method takes a name or index and returns the associated value.
Since 0.01
name
name(Str $key) (Str | Undef)
The name method takes a name or index and returns index if the the associated value exists.
Since 0.01
set
set(Str $key, Any $value) (Any)
The set method takes a name or index and sets the value provided if the associated argument exists.
Since 0.01
unnamed
unnamed() (HashRef)
The unnamed method returns an arrayref of values which have not been named using the named
attribute.
Since 0.01
- unnamed example 1
-
package main; use Venus::Vars; my $vars = Venus::Vars->new( value => { USER => 'cpanery', HOME => '/home/cpanery', }, named => { root => 'HOME', }, ); my $unnamed = $vars->unnamed; # { USER => "cpanery" }
AUTHORS
Cpanery, cpanery@cpan.org
LICENSE
Copyright (C) 2021, Cpanery
Read the "license" file.