Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: should a module export FUNCTIONS or VARIABLES?

by bikeNomad (Priest)
on Jul 02, 2001 at 20:44 UTC ( [id://93232]=note: print w/replies, xml ) Need Help??


in reply to should a module export FUNCTIONS or VARIABLES?

I'd prefer not exporting anything unless the caller asked (look at the Exporter manual page). Note that (as far as I know) there are no (or few) modules in the core distribution that automatically export variables. For example, if I use File::Find I get find() shoved into my namespace, but still have to access $File::Find::name to get the full name. Likewise for $Data::Dumper::Purity and so on.

Remember that if they have to, your users can always use the fully-qualified name of your variable. But it's better to provide access to package data via a method, and even better to not export anything and use the OO interface.

I often use modules and explicitly import nothing at all:

use File::Find ();

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-16 23:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found