Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: use base 'XYZ' and exporting

by ihb (Deacon)
on May 29, 2005 at 18:46 UTC ( [id://461556] : note . print w/replies, xml ) Need Help??

in reply to use base 'XYZ' and exporting

If you want to inherit, use base. If you want to import, call import. (If you want to import constants and benefit from constant folding, use use to import.) Those are the simple ideas.

use MyOOModule qw/ THE CONSTANTS /; use base 'MyOOModule';
If you make it so that base exports, you can't control what to import. Then you have to rely on @EXPORT, and can't use tags nor refuse to import.

Personally I almost always name what I import, so that when I or someone else return to the code, it'll be clear from where a function was imported.

For similar reasons I'd like to advice against using import to set up inheritance unless you really have to, since that is what base is for, and it'll surprise people who read your code.


See perltoc if you don't know which perldoc to read!