in reply to Re^2: Code Review of Visitor Logging Script
in thread Code Review of Visitor Logging Script

Please, at the very least, verify that your code is syntactically correct. As mentioned in perlrun, you can use `perl -c` to check the syntax of a code without executing it. You'll probably also be interested in use diagnostics; which helps to explain perl's error messages.

Running `perl -Mdiagnostics -wc 454918.pl` returned several problems:

Bareword found where operator expected at 454918.pl line 1, near "/usr/bin" (#1)
(S syntax) The Perl lexer knows whether to expect a term or an operator. If it sees what it knows to be a term when it was expecting to see an operator, it gives you this warning. Usually it indicates that an operator or delimiter was omitted, such as a semicolon. (Missing operator before bin?)
Unquoted string "bin" may clash with future reserved word at 454918.pl line 1 (#2)
(W reserved) You used a bareword that might someday be claimed as a reserved word. It's best to put such a word in quotes, or capitalize it somehow, or insert an underbar into it. You might also declare it as a subroutine.
Unquoted string "perl" may clash with future reserved word at 454918.pl line 2 (#2) syntax error at 454918.pl line 1, near "/usr/bin" "use" not allowed in expression at 454918.pl line 2, at end of line BEGIN not safe after errors--compilation aborted at 454918.pl line 3 (#3)
(F) Probably means you had a syntax error. Common reasons include: A keyword is misspelled. A semicolon is missing. A comma is missing. An opening or closing parenthesis is missing. An opening or closing brace is missing. A closing quote is missing. Often there will be another error message associated with the syntax error giving more information. (Sometimes it helps to turn on -w.) The error message itself often tells you where it was in the line when it decided to give up. Sometimes the actual error is several tokens before this, because Perl is good at understanding random input. Occasionally the line number may be misleading, and once in a blue moon the only way to figure out what's triggering the error is to call perl -c repeatedly, chopping away half the program each time to see if the error went away. Sort of the cybernetic version of S<20 questions>.
Uncaught exception from user code: syntax error at 454918.pl line 1, near "/usr/bin" "use" not allowed in expression at 454918.pl line 2, at end of line BEGIN not safe after errors--compilation aborted at 454918.pl line 3.

Please expend some time trying to resolve the errors in your own code before asking others! If nothing else, you should have noticed that the interpreter should be #!/usr/bin/perl, not !/usr/bin/perl

UPDATE: While I grant the above errors are due to the interpreter line, which may be a typo, the OP has failed to resolve problems which have been pointed out in Re^2: please help to exclude my own IP address. (fixed 5 days and 2 threads later) and Re: Code Review of Visitor Logging Script (not yet fixed). Even after:

The code still has problems. The intent of this post was not to list the compiler warnings for a potential typo, rather to empower the OP to start syntax checking his own code.

Replies are listed 'Best First'.
Re^4: Code Review of Visitor Logging Script
by Anonymous Monk on May 08, 2005 at 15:40 UTC
    i try to solve this. Will this right:
    $ips = {127.0.0.1};
    how will better:
    unless ($ENV{REMOTE_ADDR} =~ ?10.10.0.1?){ ... }
    or
    if ($ENV{REMOTE_ADDR} ne '10.10.0.1') { the code.. }