Is there any alias available in Perl to refer to the module name?

I have several Perl modules. Package names look great

every time I access functions from these modules, I need to provide something like this

&PackageName::Functionname()

is there a shortcut or alias available in Perl that can refer to packages with larger names

thanks

Kartik

+4
source share
2 answers

You can call a function without & :

 PackageName::Functionname(); 

There is also an exporter mechanism that exports a function from the module to the default namespace:

 use PackageName 'Functionname'; Functionname(); 

For further explanations on how to use use see http://perldoc.perl.org/functions/use.html

How to export functions when writing custom modules, see http://perldoc.perl.org/Exporter.html

+5
source

With Package::Alias you can specify the name of the long package, for example Foo::Bar::Baz - baz :

 use Package::Alias 'baz' => 'Foo::Bar::Baz'; baz::quux; # Invokes Foo::Bar::Baz::quux; 
+8
source

All Articles