LiTinOveWeedle has asked for the wisdom of the Perl Monks concerning the following question:

Hi I wrote csv file database script. This use html templates to view record. This scripts running well - you can see demo here.(try Show all record hyperlink) But when I try to run them as SSI by this command:

this happened:

1. scipt is called and executed (I can see it in my log)
2. cripts print as output html code(which I also log into log file to see this code - it's allright)
3. but in html page from which I called script by SSI only part of this code is inserted.
It depend on lenght of generated html code. if its short nothing is entered on this position, if its long only part (I mean after 300 chars) is inserted.
BUT when I called scripts directly from url it generated right same code but all code is sent to browser.

My source scripts are at this page.
If you know what can cause this problem please help me. It will help not only to me but also to user who use this scripts and which report this problem to me. I test this bug on Sambar4.3 and 4.4 (www.sambar.com) web server and perl ActiveState 5.6.0.

Many thanks
Litin

Replies are listed 'Best First'.
buffering problem? Re: SSI and perl script problem
by andye (Curate) on Mar 16, 2001 at 17:27 UTC
    LiTinOveWeedle, could this be a buffering problem?

    If you haven't already, try setting
    $| = 1;
    $| is also known as $OUTPUT_AUTOFLUSH if you use English - if you set it to a true value, then bufferring is (effectively) switched off.

    The Camel Book says:
    $|
    $OUTPUT_AUTOFLUSH
    autoflush HANDLE EXPR
    If set to nonzero, forces an fflush(3) after every write or print on the currently selected output channel. (This is called "command buffering". Contrary to popular belief, setting this variable does not turn off buffering.) Default is 0, which on many systems means that STDOUT will default to being line buffered if output is to the terminal, and block buffered otherwise. Setting this variable is useful primarily when you are outputting to a pipe, such as when you are running a Perl script under rsh and want to see the output as it's happening. This has no effect on input buffering. If you have a need to flush a buffer immediately after setting $|, you may simply print ""; rather than waiting for the next print to flush it. (Mnemonic: when you want your pipes to be piping hot.)

    The Perl Cookbook explains this in some detail: see section 7.12 - it also gives examples. And it says 'See Also':
    The $| entry in perlvar (1), and in the "Special Variables" section of Chapter 2 of Programming Perl; the documentation for the standard FileHandle and IO::Handle modules (also in Chapter 7 of Programming Perl ); the select function in perlfunc (1) and in Chapter 3 of Programming Perl

    Hope this helps - andy.

      Yes, Andy you'r right. I add this to to header and now all is all right. So Perl bless you.

      Li Tin O've Weedle
      mad Tsort's philosopher

Re: SSI and perl script problem
by LiTinOveWeedle (Scribe) on Mar 16, 2001 at 16:12 UTC
    Sorry SSI command missing: <!--#exec cgi="/cgi-bin/csv/readcsvplus.pl?config=testcpu.pl&sort_d=cpumark&template=0"-->