Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: use base 'XYZ' and exporting

by ihb (Deacon)
on May 29, 2005 at 18:46 UTC ( #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!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://461556]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2020-10-21 13:17 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (217 votes). Check out past polls.