Is there a Perl module or technique that makes using long namespaces easier?

Posted by Robert P on Stack Overflow See other posts from Stack Overflow or by Robert P
Published on 2011-02-17T22:31:41Z Indexed on 2011/02/17 23:25 UTC
Read the original article Hit count: 392

Filed under:
|

Some namespaces are long and annoying. Lets say that i downloaded hypothetical package called FooFoo-BarBar-BazBaz.tar.gz, and it has the following modules:

FooFoo::BarBar::BazBaz::Bill
FooFoo::BarBar::BazBaz::Bob
FooFoo::BarBar::BazBaz::Ben
FooFoo::BarBar::BazBaz::Bozo
FooFoo::BarBar::BazBaz::Brown
FooFoo::BarBar::BazBaz::Berkly
FooFoo::BarBar::BazBaz::Berkly::First
FooFoo::BarBar::BazBaz::Berkly::Second

Is there a module or technique I can use that's similar to the C++ 'using' statement, i.e., is there a way I can do

using FooFoo::BarBar::BazBaz;

which would then let me do

my $obj = Brown->new();

ok $obj->isa('FooFoo::BarBar::BazBaz::Brown') ;  # true
# or...
ok $obj->isa('Brown'); # also true

© Stack Overflow or respective owner

Related posts about perl

Related posts about namespaces