Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
P is for Practical
 
PerlMonks  

Re: Using "USE" instead of "DO" for subroutines call in external file

by tucano (Scribe)
on May 27, 2005 at 09:04 UTC ( [id://461048]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Using "USE" instead of "DO" for subroutines call in external file

Have you tried this?:
Package mysub; sub 1 { } sub 2 { } 1;
In the Caller you can say at the start of the script: require mysub; And use the module only when you really need it with: use mysub;

Replies are listed 'Best First'.
Re^2: Using "USE" instead of "DO" for subroutines call in external file
by Anonymous Monk on May 27, 2005 at 11:48 UTC
    Mr Tucano,
    use the module only when you really need it
    Thanks for the reply.
    But how do I know I really need it? i.e. with *use*
    Also having read,pointer by Mr,Displeaser below. Do I need to put all that bell and whistles? (e.g. ISA,etc)
      From O'reilly Perl Cookbook:

      Problem
      You have a module that you don't need to load each time the program runs, or whose inclusion you wish to delay until after the program starts up.

      A related situation arises in programs that don't always use the same set of modules every time they're run. For example, the factors program from Chapter 2, Numbers, needs the infinite precision arithmetic library only when the -b command-line flag is supplied. A use statement would be pointless within a conditional because it's evaluated at compile time, long before the if can be checked. So we'll use a require instead:
      if ($opt_b) { require Math::BigInt; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://461048]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.