Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Using a module more than once

by jeteve (Pilgrim)
on Aug 02, 2005 at 15:24 UTC ( [id://480228]=note: print w/replies, xml ) Need Help??


in reply to Using a module more than once

Hi. I don't think putting several
use Foo ;
on your code will load many times the module in the memory. IMHO, once the module is loaded in memory by the first use, the following use has no effect. So if you need to explicitely use the module Foo in your module, just write use Foo; at the head. If other developpers use the same modules as you in their code, that will cause no problem at all. Hope it helps !
Nice photos of naked perl sources here !

Replies are listed 'Best First'.
Re^2: Using a module more than once
by Mutant (Priest) on Aug 02, 2005 at 15:32 UTC
    Correct. Perl maintains a global %INC hash, listing all modules that have been required (use is just a special case of require). If a reference to the file already exists in %INC, it will not be loaded a second time.

    If you wanted to force Perl to reload the module, you could delete the reference to it in %INC (the key is the file name, which can be absolute, or relative to one of the directories in @INC). There aren't many cases where you'd want to do this, of course. (One legitimate case is Apache::Reload).
Re^2: Using a module more than once
by dave_the_m (Monsignor) on Aug 02, 2005 at 15:44 UTC
    IMHO, once the module is loaded in memory by the first use, the following use has no effect
    Not entirely true. Subseqent use's don't load the file again, but they still call the import method of the use'd class.

    Dave.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-18 14:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found