I'm trying to create a simple cgi perl script that counts down from 10 to 0; however I can't seem to get it to work. It keeps telling me malformed header from script. Bad header=HTTP/1.1 200 OK
. I'm new to Perl and CGI scripting so I'm sure it's something really simple.
#!/usr/bin/perl
use warnings;
use strict;
use CGI::Push qw(:standard);
my $startingCountDown = 10;
do_push(-next_page => \&refresh, -last_page=> \&lastPage, -delay => 1 );
sub refresh
{
my ($cgi, $count) = @_;
return undef if ($startingCountDown - $count < 0);
my $num = $startingCountDown - $count;
my $page = $cgi->start_html();
$page .= $cgi->p("The count is $num").end_html();
return $page;
}
sub lastPage
{
my ($cgi, $count) = @_;
return start_html()."Blast Off".end_html();
}
If I run this from terminal (on my Macbook) I get the following error: WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY.
. I've tried running this script in both Safari and Chrome but neither seems to work. In that case, how would I write a functioning script that counts down from 10 to 1, changing numbers every second? Thanks.