Page counter
#!/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;
Related examples in the same category