No such thing as a small change | |
PerlMonks |
Re: Making it clearer to say that a sub is defined within current package (package aliasing)by LanX (Saint) |
on Apr 11, 2019 at 17:20 UTC ( [id://1232463]=note: print w/replies, xml ) | Need Help?? |
This is pretty clean, put your private stuff into a sub-package and alias that long package path it to a shorter package name at compile time. (of course these subs won't be able to call imported subs in the parent package without full qualification or inheritance ;-)
Cheers Rolf
updatethe magic in the BEGIN/END blocks could be done in the importer of a module called with use PackageAlias "X::Y:Z::my" => "my" and no PackageAlias "my"
UpdateI just realised that Package::Alias already exists, even with a pretty similar interface. Skipped colons in my example to avoid confusion.
In Section
Seekers of Perl Wisdom
|
|