namespace
view release on metacpan or search on metacpan
namespace.pm view on Meta::CPAN
Albert MICHEEV <amichauer@cpan.org>
=cut
use strict qw/subs vars/;
$namespace::VERSION = '0.05';
sub import{
my ($slf, $als, $pkg) = (shift, shift, shift);
my $clr = (caller)[0];
$als = $clr.$als if substr($als, 0, 2) eq '::';
die "Package '$als' already defined!" if defined %{$als.'::'};
require join( '/', split '::', $pkg ) . '.pm' unless defined %{$pkg.'::'};
@{$als.'::ISA'} = $pkg;
if( @_ and $_[0] eq '()' ){ shift }
else{ unshift @_, @{$pkg.'::EXPORT'} if defined @{$pkg.'::EXPORT'} }
namespace.pm view on Meta::CPAN
!$1 ? \&{$Pkg.'::'.$2} :
$1 eq '$' ? \${$Pkg.'::'.$2} :
$1 eq '@' ? \@{$Pkg.'::'.$2} :
\%{$Pkg.'::'.$2};
}
else{ die "Undefined behavior!\n" }
}
}
sub unimport{
undef %{(substr($_[1], 0, 2) eq '::' ? (caller)[0] : '' ).$_[1].'::'};
}
1;
( run in 0.481 second using v1.01-cache-2.11-cpan-a3c8064c92c )