xsize 0 Report post Posted October 20, 2004 My Second Perl ProgrammThe Simple counter...u must create the file:counter.dat [br]#!/usr/bin/perl[/br]#counter.cgi[br][/br]urldecode{[br] local($val)=@_;[/br] $val=~s/\+/ /g;[br] $val=~s/%([0-9a-hA-H]{2})/pack('C',hex($1))/ge;[/br] return $val[br]}[/br]$dataf:='couner.dat';[br]open(F,"+<$dataf") || die "can't open file counter.dat";[/br]flock(F,$LOCK_EX);[br][/br]@cnt=<F>;[br]$Dat=@cnt[/br]$ip=$ENV('REMOTE_ADDR');[br][/br]($count,$ip)=split(/\s+/,@Dat);[br]$count++;[/br]$Dat=join(' ',$count,$ip);[br]fseek(F,0,0);[/br]print F "$Dat";[br]truncate(F,tell(F));[br][/br]flock(F,$LOCK_UN);[/br]close(F);[br][/br]print "Content-Type: text/html\n\n";[br]print "<HTML><BODY><CENTER><small>";[/br]print "$Dat";[br]print "<\small><\CENTER><\BODY><HTML>";[/br] Share this post Link to post Share on other sites