Don't ask to ask, just ask | |
PerlMonks |
Re: Code Reuseby LanX (Saint) |
on Aug 20, 2017 at 17:58 UTC ( [id://1197710]=note: print w/replies, xml ) | Need Help?? |
A use is basically a require plus a call to the import sub of the included package. And import is executed in the context of the calling package. Thus you can call other imports inside a generic import to export into the calling namespace. For instance:
You might wanna have a look into the source of Modern::Perl for more examples.
Cheers Rolf
Update
*) Had to change require strict; to use strict; to make it work.
AnswerIt's a timing issue, the require has to happen in a BEGIN or inside the import (use does it automatically), this works
In Section
Seekers of Perl Wisdom
|
|