Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Exporting functions into main namespace for the benefit of other use'd modules

by SmokeyB (Scribe)
on Jul 11, 2003 at 18:39 UTC ( [id://273521]=note: print w/replies, xml ) Need Help??


in reply to Exporting functions into main namespace for the benefit of other use'd modules

Personally, this is what I would do when creating and importing my module. Creating module:
package YourModule; require Exporter; use strict; use vars qw(@ISA @EXPORT @EXPORT_OK); @ISA = qw(Exporter); @EXPORT = qw(get_id AnotherSub); @EXPORT_OK = qw(evenMoreSubs justOneMore);
Under @EXPORT place all of the subroutines that will use in all your other modules, and then call it like so:
use YourModule qw (:DEFAULT); use strict; my $id = get_id();
If you include the :DEFAULT tag, it will use all subroutines from @EXPORT. This should do what you're looking for. Cheers!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-25 13:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found