Kage has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl $count_file = "count.txt"; $ip_file = "ips.txt"; $ip=$ENV{'REMOTE_ADDR'}; $time=localtime( time ); open(COUNT,"$count_file") || die("Perl SNAFU $!"); ($count) = <COUNT>; close(COUNT); $count =~ s/\n//; open(FILE,$ip_file) || die("Perl SNAFU $!"); @data=<FILE>; close(FILE); $countem="0"; foreach $lines (@data) { chop($lines); ($ips,$times,)=split('=',$lines); if ($ip =~ /$ips/i) { if (-M /$times/i > 1) { $countem="0"; } else { $countem="1"; } # End IfTimes } else { $countem="1"; } # End IfIps } # End ForEach if ($countem) { $count++; open(COUNT,">$count_file") || die("Perl SNAFU $!"); print COUNT "$count"; close(COUNT); open(WRITE,">>$ip_file") || die("Perl SNAFU $!"); print WRITE "$ip=$time\n"; close(WRITE); } # End IfCount print "Content-type: text/html\n\n"; print "<\!--\n"; print "document.write(\"$count\");\n"; print "//-->";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Counter that won't work with the IP Log
by mitd (Curate) on Nov 15, 2001 at 14:08 UTC | |
Re: Counter that won't work with the IP Log
by Kanji (Parson) on Nov 15, 2001 at 12:38 UTC | |
Re: Counter that won't work with the IP Log
by Kage (Scribe) on Nov 15, 2001 at 12:31 UTC |