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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Code Review of Visitor Logging Script
by eibwen (Friar) on May 07, 2005 at 18:17 UTC

    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)
    Unquoted string "bin" may clash with future reserved word at 454918.pl line 1 (#2)
    
    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)
    
    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:

    • Fixing the interpreter
    • changing use warning; to use warnings;
    • removing the additional /^+/ prefixes
    • declaring the variables with my in the proper scope

    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.

      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.. }