How to Install and Uninstall perl-MooseX-Attribute-ENV Package on openSuSE Tumbleweed

Last updated: June 26,2024

1. Install "perl-MooseX-Attribute-ENV" package

This is a short guide on how to install perl-MooseX-Attribute-ENV on openSuSE Tumbleweed

$ sudo zypper refresh $ sudo zypper install perl-MooseX-Attribute-ENV

2. Uninstall "perl-MooseX-Attribute-ENV" package

Learn how to uninstall perl-MooseX-Attribute-ENV on openSuSE Tumbleweed:

$ sudo zypper remove perl-MooseX-Attribute-ENV

3. Information about the perl-MooseX-Attribute-ENV package on openSuSE Tumbleweed

Information for package perl-MooseX-Attribute-ENV:
--------------------------------------------------
Repository : openSUSE-Tumbleweed-Oss
Name : perl-MooseX-Attribute-ENV
Version : 0.02-2.24
Arch : noarch
Vendor : openSUSE
Installed Size : 10.4 KiB
Installed : No
Status : not installed
Source package : perl-MooseX-Attribute-ENV-0.02-2.24.src
Upstream URL : http://search.cpan.org/dist/MooseX-Attribute-ENV/
Summary : Set default of an attribute to a value from %ENV
Description :
This is a Moose attribute trait that you use when you want the default
value for an attribute to be populated from the %ENV hash. So, for example
if you have set the environment variable USERNAME = 'John' you can do:
package MyApp::MyClass;
use Moose;
use MooseX::Attribute::ENV;
has 'username' => (is=>'ro', traits=>['ENV']);
package main;
my $myclass = MyApp::MyClass->new();
print $myclass->username; # STDOUT => 'John';
This is basically similar functionality to something like:
has 'attr' => (
is=>'ro',
default=> sub {
$ENV{uc 'attr'};
},
);
but this module has a few other features that offer merit, as well as being
a simple enough attribute trait that I hope it can serve as a learning
tool.
If the named key isn't found in %ENV, then defaults will execute as normal.