Data::Object::Vars
Data-Object Environment Variables
use Data::Object::Vars; my $vars = Data::Object::Vars->new( 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}
This package provides an object-oriented interface to the process' environment variables.
This package integrates behaviors from:
Data::Object::Role::Stashable
This package uses type constraints defined by:
Data::Object::Library
This package has the following attributes.
named(HashRef)
The attribute is read-only, accepts (HashRef) values, and is optional.
(HashRef)
This package implements the following methods.
exists(Str $key) : Any
The exists method takes a name and returns truthy if an associated value exists.
$vars->exists('home'); # exists $ENV{HOME} $vars->exists('HOME'); # exists $ENV{HOME}
get(Str $key) : Any
The get method takes a name and returns the associated value.
$vars->get('home'); # $ENV{HOME} $vars->get('HOME'); # $ENV{HOME}
name(Str $key) : Any
The name method takes a name and returns stash key if the the associated value exists.
$vars->name('root'); # HOME $vars->name('home'); # HOME $vars->name('HOME'); # HOME
set(Str $key, Maybe[Any] $value) : Any
The set method takes a name and sets the value provided if the associated argument exists.
$vars->set('home', '/tmp'); # /tmp $vars->set('HOME', '/tmp'); # /tmp
stashed() : HashRef
The stashed method returns the stashed data associated with the object.
$vars->stashed; # {...}
Al Newkirk, +309
+309
Anthony Brummett, +10
+10
Adam Hopkins, +2
+2
José Joaquín Atria, +1
+1
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To get the most out of this distribution, consider reading the following:
Do
Data::Object
Data::Object::Class
Data::Object::ClassHas
Data::Object::Role
Data::Object::RoleHas
To install Do, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Do
CPAN shell
perl -MCPAN -e shell install Do
For more information on module installation, please visit the detailed CPAN module installation guide.