in reply to Re: simple IP counter..
in thread simple IP counter..

For a guess, you're wondering (did you forget to ask a question?) why this won't compile.

use strict; use Fcntl ':flock'; #792341 my ($mday,$mon,$year) = (localtime(time))[3,4,5]; $year=$year+1900; if ($mday < 10) { $mday = "0$mday"; } if ($mon < 10) { $mon = "0$mon"; } my $month = ++$mon; my $date = "$mday.$month.$year"; my $file = "counter.txt"; my $host = $ENV{'REMOTE_HOST'}; my $ip = $ENV{'REMOTE_ADDR'}; my ($uq,@counter,@counter_data); open(COUNTER, "$file") || &error("cannot open file for read"); @counter = <COUNTER>; close(COUNTER); for(@counter) { chomp; @counter_data = split (/\|/, $_); if ($counter_data[0] eq $date && $counter_data1 eq $ip && $counte +r_d +ata2 eq $host) { $uq = 1; } } if (!$uq) { open (COUNTER, ">>$file") || &error("cannot open file for +write"); flock (COUNTER, 2); print COUNTER "$date|$ip|$host\n" or die; close(COUNTER) or die; } sub error { my $error = $_[0]; print "$error\n"; exit; }

Some answers, found with perl -c 792341.pl

Global symbol "$counter_data1" requires explicit package name at 79234 +1.pl line 30. Global symbol "$counter_d" requires explicit package name at 792341.pl + line 30. Bareword "ata2" not allowed while "strict subs" in use at 792341.pl li +ne 30. 792341.pl had compilation errors.

Please see Writeup Formatting Tips and Markup in the Monastery.

And it wouldn't hurt to include use warnings; along with strict.

Update: Missed the missing "[...]". Corrected that and the error messages