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

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)
  • Comment on Re^2: Using "USE" instead of "DO" for subroutines call in external file

Replies are listed 'Best First'.
Re^3: Using "USE" instead of "DO" for subroutines call in external file
by tucano (Scribe) on May 31, 2005 at 13:05 UTC
    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; }