



(12 votes)#!/usr/bin/perl ##################################### # # # Example of how to make # # a basic counter in perl # # # # By Snap # # (iam@someoneshouse.com) # # # # For Metalshell # # http://www.metalshell.com # # # # In order for it to work you need # # to create a file called counter # # in the same directory as the cgi. # # Empty to start from 0 # # # ##################################### print "Content text:html/text\n\n"; open(OFILE,"counter") || `cat /dev/null > counter;chmod 664 counter`; $ctr=<OFILE>; $ctr++; close(OFILE); print << "EOF"; <html> <title>Example of a Counter</title> <body bgcolor=gray> <table border=0 valign=center align=center> <tr> <td> Main Body of Web page </td> </tr> <tr> <td align=center valign=bottom> You are visitor number: $ctr </td> </tr> </table> </body> </html> EOF open(WRITE,">counter"); print WRITE $ctr; close(WRITE);