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

thanks a million. It works fine now. However, timing the two instances "do" versus "use", seems that 'do' is faster: with "use":
1.01user 0.01system 0:01.09elapsed 94%CPU
with "do":
0.94user 0.01system 0:01.03elapsed 93%CPU
Would you suggest I stick to "do"?

Replies are listed 'Best First'.
Re^5: Using "USE" instead of "DO" for subroutines call in external file
by Zaxo (Archbishop) on May 27, 2005 at 07:53 UTC

    I think you should worry less about speed. The numbers you show are not a significant time difference for a statement which will only run once in a non-trivial program. Particularly not for a disk I/O operation which may be influenced that much by head position or system traffic.

    A better criterion is to consider how soon your program should know about your subs. By loading at compile time with use, perl knows the location and properties of your subs at compile time. With that, for instance, subs prototypes become effective, where they would be ignored if loaded at runtime. That may even gain you some speed at runtime.

    Note: Don't go stick prototypes on everything! They're much misunderstood and rarely necessary.

    After Compline,
    Zaxo