Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Using 'use' away from script start

by ehdonhon (Curate)
on Nov 15, 2001 at 08:48 UTC ( [id://125508]=note: print w/replies, xml ) Need Help??


in reply to Using 'use' away from script start

As Ovid mentioned, Perl does all the use'ing at compile time no matter where it lives in your code. As an insteresting aside, it turns out that it will even evaluate use statements prior to optimizing your code. So even if you do something like this:

if ( 0 ) { use MyModule; }

Perl will still load MyModule.

If you really only want to load that module whenever that function is called, then you need to require() the module instead of use'ing it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://125508]
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: (4)
As of 2025-03-26 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (68 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.