Try this code and name the script nph-something.pl.
I haven't tested it, but it should work. The problem with using the nph mode of the webserver with a script is that the script must now supply all of the standard headers itself.
Using the CGI header() function automatically provides these for you.
#! /perl/bin/perl -w
use strict;
use CGI;
my $q = new CGI;
print $q->header(-nph=>1);
print "<html><body>";
for my $i (1..5) {
my $data = "<br>Line $i";
sleep 1;
print $data;
}
print "</body></html>";