programming-examples/perl/CGI/Page counter.pl
2019-11-15 12:59:38 +01:00

38 lines
573 B
Perl

#!/usr/bin/perl
use CGI;
$co = new CGI;
open (COUNT, "<count.dat")
or die "Could not open counter data file.";
$count = <COUNT>;
close COUNT;
$count++;
open (COUNT, ">count.dat");
print COUNT $count;
close COUNT;
print
$co->header,
$co->start_html(
-title=>'Counter Example',
-author=>'your Name',
-BGCOLOR=>'white',
),
$co->center($co->h1('Counter Example')),
$co->p,
$co->center($co->h3("Current count: ", $count)),
$co->p,
$co->center($co->h3("Reload the page to update the count")),
$co->end_html;