开发者

Is there any alias available in Perl for referencing a module name?

I have multiple Perl modules. The package names seems to be big

everytime i access t开发者_如何学编程he 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜