in reply to Which is better - one large file or multiple files?

One file is always faster than many if you are loading the whole mess each time.

Many files makes for cleaner development, and gives you the option of dividing one CGI into many, each of which loads far less data.

My rule of thumb is that by the time it is big enough for the performance difference between one and many files to matter, the performance advantage of having many files so that you don't load it all at once wins. And if loading time is a problem, then you should probably be using mod_perl...

UPDATE
An incidental note. A vague memory is telling me that you might have issues with misplaced line-numbers if you have more than 64K lines in a single source file. That is another reason to use multiple files.

  • Comment on Re (tilly) 1: Which is better - one large file or multiple files?

Replies are listed 'Best First'.
Re: Re (tilly) 1: Which is better - one large file or multiple files?
by George_Sherston (Vicar) on Aug 10, 2001 at 04:23 UTC
    Of course, if you're feeling daring, you can put your subroutine sub foo in a different file by saving it as foo.pl then, as and when your main script needs it, call it with
    do 'foo.pl';
    The disadvantage of this is that it doesn't get compiled unless and until you call it.
    The advantage is, it doesn't get compiled unless and until you call it.

    § George Sherston
      It is better to use Perl's AUTOLOAD for delayed loading. After all that is what it is for.

      If you just want to be able to take your program and force lazy loading of subroutines, you can use AutoLoader to do the loading and AutoSplit to split your file. That will perform much better on repeated calls to the function, and you can develop with a single huge file if you want.