in reply to CGI print statements taking forever

In your example, you're needlessly concatinating the string, before you print it. You should see a slight speed up from changing periods to commas:

print $content{'menu'}, $content{'body'}, $content{'footer'};

Replies are listed 'Best First'.
Re^2: CGI print statements taking forever
by traxlog (Scribe) on Jun 27, 2005 at 11:14 UTC
    Yep, tried that, and I've also tried :
    print $content{'menu'}; print $content{'body'}; print $content{'footer'};
    and
    print <<HTML; $content{'menu'} $content{'body'} $content{'footer'} HTML
    All solutions only shaving milliseconds off the total time.

      If you've gotten it down to that particular block of code, can you manage to break it down further, and track down exactly which line is the worst offendor?

      The only times I've seen print be a major problem was when I was passing around rather large strings through a series of functions (by 'rather large', they were in excess of a 500k), concatinating as it went through the functions.) -- so it wasn't really the print, it was the concatination, and assigning large strings based on the return of the functions. We changed the logic so we were passing around an array of strings, and printing that, and it shaved a few seconds off our time.

      Also, be careful of the "<<HTML" example that you've given -- it would also insert extra line returns (probably not an issue for HTML, but could be an issue for other situations