On Thu, 31 May 2001, Nichole Bialczyk wrote:

> i'm sorry. i didn't think that you guys would want me to include my code.
> i just assumed that i should try to make my question to the point with as
> little text as possible. i am still having the same problem (and i do
> have the "). here is my exact code:

Code samples can illustrate the nature far more accurately than a
description of the code can.  It's always best to include problematic code
when you are trying to get help on it.

> sub log {
>    if (open(LOG,">$logfile")) {

You should check for errors when you open a file:

open(LOG, ">$logfile") or die "Can't open $logfile: $!\n";

If you don't know what the error is, you'll never track down the bug.

>       print "Content-type: text/html\n\n";
>       print "Couldn't open $logfile. $!\n";
>       print "At $date, $ENV{'REMOTE_HOST'} couldn't enter the site.";
>       exit;
>    }
>    print LOG "At $date, $ENV{'REMOTE_HOST'} came here using
> $ENV{'HTTP_USER_AGENT'}.\n";
>    close (LOG);
> }

You have a serious logic error here.  Going by the code, if the open file
is successful, it prints the three lines, and then the script exits.  If
the open fails, then you try writing to the file, which you can't do,
because the open failed.

-- Brett

Brett W. McCoy
Software Engineer
Broadsoft, Inc.
240-364-5225
[EMAIL PROTECTED]



Reply via email to