print new line? - can't get it to work (Posted by Justin Stayton)
Ok, here is my problem: in my cgi script i have a file named LOG open, and I'm trying to print a IP address and then a new line so when the next person accesses the script it will print their IP and then a new line. But I can't get it to work, it just prints the IP address, but not a new line. So when the next person accesses it it just writes over the last IP address.
CODE:
open(LOG, "$logfile");
$log = <LOG>;
close (LOG);
open(LOG, ">$logfile");
print LOG "$visitorip";
print LOG "\n";
close (LOG);
----------
[red]FireBurn Web Publishing[/red]: fireburn.com
Low cost web design, graphic design, and more!
Justin Stayton - [email] [icq]
Federico Carnales posted this at 20:49 — 31st October 1999.
They have: 69 posts
Joined: Apr 1999
change:
open(LOG, ">$logfile") ;
to:
open(LOG, ">>$logfile") ;
> Creates a new file (and if it already exists, it overwrites the old one)
>> Opens a file for appending (if it doesn't exists, it tries to create one)
Cheers!
----------
Reviews of the best resources for webmasters in your e-mail every week!
Subscribe for [red]FREE[/red] by going to http://www.web-reviews.com/
Justin S posted this at 21:19 — 31st October 1999.
They have: 2,076 posts
Joined: Jun 1999
Thanks, it works now.
----------
[red]FireBurn Web Publishing[/red]: fireburn.com
Low cost web design, graphic design, and more!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.