Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

So what went wrong??

Status
Not open for further replies.

mtorbin

Technical User
Nov 5, 2002
369
US
Here's the code:

#!/usr/bin/perl -wT

use CGI qw/:standard/;
use CGI::Cookie;

%cookies = fetch CGI::Cookie;
my $emailCookie = $cookies{'peiEmail'}->value;
my $ipCookie = $cookies{'peiIP'}->value;

my $fileName = substr $ENV{"QUERY_STRING"},9;
my $fileLoc = ' . $fileName;
my $timeStamp = 'TODAY';

$logEntry = $emailCookie . '|' . $ipCookie . '|' . $timeStamp . '|' . $fileName . "\n";

open (LOG, ">>ftpLog.txt");
flock (LOG, 2);
print LOG "$logEntry";
close (LOG);

Here's the error messages:

flock() on closed filehandle LOG at /var/print() on closed filehandle LOG at /var/
What gives?

- MT
 
ftpLog.txt never Opened! You should put a "die" statement there and use:
Code:
    use CGI::Carp qw(fatalsToBrowser);

While testing for errors!

Whats the results now?

X
 
So I put that up at the top with the rest of the USE statements?

- MT
 
Yup, and change this:
Code:
open (LOG, ">>ftpLog.txt");

To this:
Code:
open (LOG, ">>ftpLog.txt") or die "file cannot be opened.";
 
So for my "learning experience", what does:

use CGI::Carp qw(fatalsToBrowser);

do?

- MT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top