CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Forcing output before script finishes



Apr 12, 2000, 12:43 PM

Post #1 of 2 (1112 views)
Forcing output before script finishes Can't Post

I have a script which unlocks a file, prints a webpage, then locks the file. The webpage initiates the download with <body onLoad="location.href=''">

The problem is that the page is not sent to the browser until the script completes, by which time the file has been relocked.

chmod(0600, "filename.exe");  # user read/write 
&PrintWebpage; # prints complete webpage
sleep(50); # gives the download a chance to start
chmod(0200, "filename.exe"); #user write only

Suggestions? Thanks.

Administrator / Moderator

Apr 12, 2000, 2:53 PM

Post #2 of 2 (1112 views)
Re: Forcing output before script finishes [In reply to] Can't Post

To make a program display its results as it executes (opposed to when the script completes), you can flush the Perl buffer by using:


$| is the variable for the perl buffer. By default, it's set to not flush (false). So by making the value 1 (true), the buffer will flush as soon as there's something to output, and will continue to do so until the program completes.

Note that while the program will flush with $|=1, the javascript onLoad command waits until all elements of the page are loaded. Depending on your images and other page elements, and the what the program does after the unlocking, there may not be enough time before the onLoad command is invoked before the file is relocked.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives