Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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.

ihb

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-24 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found