#! /usr/local/bin/perl
################################################################################
$VERSION='replace.pl v1.1'; # December 1996 Dale Bewley <dale@bewley.net>
#VERSION='replace.pl v1'; # July 1996 Dale Bewley <dale@bewley.net>
#------------------------------------------------------------------------------#
# This script and others found at: http://www.bewley.net/perl/
#
# nph-replace.pl is a simple demo of a multipart document and server push. 
# If you have always wondered how to have a CGI output some virtual HTML then 
# think for a while and output more virtual HTML now you know.
#
################################################################################
$|=1;					# don't buffer output
$BOUNDARY="start-new-page-here--";	# seperates html pages

print "HTTP/1.0 200 OK\n";
print "Pragma: no-cache\n";
print "Content-type: multipart/x-mixed-replace;boundary=$BOUNDARY\n\n";

print "--$BOUNDARY\n";			# tells browser to start a new page
print "Content-type: text/html\n\n"; 	# tells it what kind

for ($count=3; $count >= 0; $count--) {
	print "<h1>$count</h1>\n";
	sleep($count);
	print "Get ready. Here comes <b>" . ($count -1) . "</b>!\n";

	print "--$BOUNDARY\n";		     
	print "Content-type: text/html\n\n";
}

print "<h1>boom!</h1>\n";
print "</html>";	# don't forget this!

