NAME

package - makes an alias of the current package

REQUIRES

Class::ISA, Carp

SYNOPSIS

package Original;
use package "YourNameForOriginal";

sub sub_from_original { 123 }

YourNameForOriginal->Weed::Package::import("Weed::Package::XYZ", 'sub_from_XYZ');

my $value = YourNameForOriginal->sub_from_original;
my $ref   = \&YourNameForOriginal::sub_from_XYZ;

and

package main;

AA->Weed::Package::base('Original');
BB->Weed::Package::base('Original');

CC->Weed::Package::supertypes(qw'BB AA');

my $value = AA->sub_from_original;

METHODS

use

use package $name, @import;

makes an alias of the current package with the name $name and imports the symbols in @import.

name($object)

Weed::Package::name returns the package name of $object or $object;

sub new {
	bless {}, Weed::Package::name(shift);
}

exists($name)

Weed::Package::exists checks if package $name is loaded or an alias exists

return $name->new(123) if Weed::Package::exists($name);

base($package, $base, @import)

Weed::Package::base sets the base $base for package $package and imports the symbols in import in the namespace of package if package not exists then a namespace $package is created

Weed::Package::base($package, $base);

Weed::Package::base($package, $base, '$var');

Weed::Package::base($package, $base, [{'@as' => '@it', '@like' => '@it'}, qw'sub function'], 'routine', ['ggg'];

import($to, $from, @import)

imports the symbols in @import from $from to $to

Foo->Weed::Package::import('from', {'foo' => 'new'} );

superpath($package|$object)

superpath returns an ordered list of package names.

@path = Weed::Package::superpath($package);
@path = Weed::Package::superpath($object);

supertypes($package|$object)

returns the supertypes of $package or $object if the package is created with 'package'

say join ' ', CC->Weed::Package::supertypes;

supertypes($package|$object, @supertypes)

creates a new namespace $name and sets the supertypes

CC->Weed::Package::supertypes('BB', 'AA');

AUTHOR

Holger Seelig holger.seelig@yahoo.de

COPYRIGHT

This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.