I have multiple Perl modules. The package names seems to be big
everytime i access the functions from those modules, i need to provide something like this
&PackageName::Functionname()
is there a shortcut or alias available in Perl which can reference the packages with bigger names
Thanks
Karthik
With Package::Alias
you can alias a long package name such as Foo::Bar::Baz
to baz
:
use Package::Alias 'baz' => 'Foo::Bar::Baz';
baz::quux; # Invokes Foo::Bar::Baz::quux;
You can call the function without the &
:
PackageName::Functionname();
Also there is the exporter mechanism which exports function from a module to your default namespace:
use PackageName 'Functionname';
Functionname();
For further explainations how to use use
see http://perldoc.perl.org/functions/use.html
How to export functions when writing your own modules, see http://perldoc.perl.org/Exporter.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With