Page counter : Page « CGI « Perl






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

1.Track the number of times a web page has been accessed
2.Redirect a web page
3.Redirect page
4.Values Carried Between Pages
5.Logs visitors to web site
6.Server push