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 15: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; }