I have this Perl script sitting in the cgi-bin folder of my Apache server:
#!/usr/bin/perl
use strict;
use warnings;
$| = 1;
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";
my $top = 5;
foreach (1..$top) {
print "i = $_<br />\n";
sleep 1;
}
What I want to achieve here is a gradual update of the web page to show the user an updated status. However, what I'm actually getting is the entire output at once, after a delay of 5 secs.
Is there any way I can write a script that is able to continuously inform the user of its progress? I have a script that takes a long time to finish and I would like to be able to see its progress in real time rather than the whole script to finish.
I have also tried to set autoflush mode to off ($| = 0), but even that doesn't do any thing.