#!/usr/bin/env perl use strict; use warnings; use lib q(./); use T4; ## Main # my $obj_t = T4->new( name_env => q(foo) ); print q(>> ) . $obj_t->t_hello_world . qq( <<\n); $obj_t->t_set_remote(q(This is a test)); print q(>> ) . $obj_t->t_get_remote . qq( <<\n); ## END Main #### package T4; # Pragmas use strict; use warnings; use version; our $VERSION = qv('3.0.0'); use feature qw(:5.10); # Standard Modules use Data::Dumper qw(Dumper); use Class::Std::Utils qw( ident anon_scalar ); my %Attr_Name_Env; my %Attr_Remote; use T4::MyMod { Href_Attr_Name_Env => \%Attr_Name_Env, Href_Attr_Remote => \%Attr_Remote, }, qw( t_set_remote t_hello_world ) ; ## Main ## ## Constructor 'new' # sub new { ## Get and confirm arguments # my $class = shift; my $href_arg = {@_}; my $name_env = $href_arg->{'name_env'}; ## Bless anon scalar into class # my $obj_new = bless anon_scalar(), $class; my $idx_self = ident $obj_new; ## Create object attributes # $Attr_Name_Env{ $idx_self } = $name_env; return $obj_new; } ## END Constructor 'new' ## DESTROY # sub DESTROY { my $self = shift; my $idx_self = ident $self; delete $Attr_Name_Env{ $idx_self }; print STDERR qq(\nDestroyed ) . __PACKAGE__ . qq( object $idx_self\n\n); } ## END DESTROY sub t_get_name_env { my $self = shift; my $idx_self = ident $self; return $Attr_Name_Env{ $idx_self }; } sub t_get_remote { my $self = shift; my $idx_self = ident $self; return $Attr_Remote{ $idx_self }; } ## End Main ## 1; #### package T4::MyMod; use base q(Exporter); @EXPORT = qw( t_hello_world t_set_remote ); # use Data::Dumper qw(Dumper); my $Href_Attr_Name_Env; my $Href_Attr_Remote; sub import { # print STDERR Dumper(@_); my $pkg = shift; my $href_attr = shift; $Href_Attr_Name_Env = $href_attr->{Href_Attr_Name_Env}; $Href_Attr_Remote = $href_attr->{Href_Attr_Remote}; T4::MyMod->export_to_level(1, $pkg, @_); } sub t_hello_world { my $self = shift; my $idx_self = ident $self; return qq(Hello World $idx_self); } sub t_set_remote { my $self = shift; my $arg = shift; my $idx_self = ident $self; $Href_Attr_Remote->{ $idx_self } = $arg; return 1; } 1;