GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Data::Object::Vars(3) User Contributed Perl Documentation Data::Object::Vars(3)

Data::Object::Vars

Env Vars Class for Perl 5

  package main;

  use Data::Object::Vars;

  local %ENV = (USER => 'ubuntu', HOME => '/home/ubuntu');

  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 methods for accessing %ENV items.

This package integrates behaviors from:

Data::Object::Role::Buildable

Data::Object::Role::Proxyable

Data::Object::Role::Stashable

This package uses type constraints from:

Types::Standard

This package has the following attributes:

  named(HashRef)

This attribute is read-only, accepts "(HashRef)" values, and is optional.

This package implements the following methods:

  exists(Str $key) : Any

The exists method takes a name or index and returns truthy if an associated value exists.

exists example #1
  # given: synopsis

  $vars->exists('iam'); # truthy
    
exists example #2
  # given: synopsis

  $vars->exists('USER'); # truthy
    
exists example #3
  # given: synopsis

  $vars->exists('PATH'); # falsy
    
exists example #4
  # given: synopsis

  $vars->exists('user'); # truthy
    

  get(Str $key) : Any

The get method takes a name or index and returns the associated value.

get example #1
  # given: synopsis

  $vars->get('iam'); # ubuntu
    
get example #2
  # given: synopsis

  $vars->get('USER'); # ubuntu
    
get example #3
  # given: synopsis

  $vars->get('PATH'); # undef
    
get example #4
  # given: synopsis

  $vars->get('user'); # ubuntu
    

  name(Str $key) : Any

The name method takes a name or index and returns index if the the associated value exists.

name example #1
  # given: synopsis

  $vars->name('iam'); # USER
    
name example #2
  # given: synopsis

  $vars->name('USER'); # USER
    
name example #3
  # given: synopsis

  $vars->name('PATH'); # undef
    
name example #4
  # given: synopsis

  $vars->name('user'); # USER
    

  set(Str $key, Maybe[Any] $value) : Any

The set method takes a name or index and sets the value provided if the associated argument exists.

set example #1
  # given: synopsis

  $vars->set('iam', 'root'); # root
    
set example #2
  # given: synopsis

  $vars->set('USER', 'root'); # root
    
set example #3
  # given: synopsis

  $vars->set('PATH', '/tmp'); # undef

  # is not set
    
set example #4
  # given: synopsis

  $vars->set('user', 'root'); # root
    

  stashed() : HashRef

The stashed method returns the stashed data associated with the object.

stashed example #1
  # given: synopsis

  $vars->stashed
    

Al Newkirk, "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 terms of the The Apache License, Version 2.0, as elucidated in the "license file" <https://github.com/iamalnewkirk/data-object-vars/blob/master/LICENSE>.

Wiki <https://github.com/iamalnewkirk/data-object-vars/wiki>

Project <https://github.com/iamalnewkirk/data-object-vars>

Initiatives <https://github.com/iamalnewkirk/data-object-vars/projects>

Milestones <https://github.com/iamalnewkirk/data-object-vars/milestones>

Contributing <https://github.com/iamalnewkirk/data-object-vars/blob/master/CONTRIBUTE.md>

Issues <https://github.com/iamalnewkirk/data-object-vars/issues>

2020-03-20 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.