Gossamer Forum
Home : General : Perl Programming :

Deleting File Contents

Quote Reply
Deleting File Contents
This may sound dumb, but how do I delete the previous contents of a file so I can write a new thing in there? (this would be done through CGI, using the open (LOG)">>../smee/$rating tag (That's not exactly right, but you get the idea...

Hey, if you can help with this, try helping my 'Average' post! :)

Quote Reply
Re: Deleting File Contents In reply to
Assuming that you just want to overwrite the previous contents of the file, use:

open (LOG, ">/<your_file_here>");

Notice the singular ">".
Using your version just appends to the file rather than overwriting it.

--Cade

Quote Reply
Re: Deleting File Contents In reply to
Ok, but when I make a second post to the same data file it discards it, and only the first remains.

Also, do you use the /< > tags? When I do my server tells me that I can't open the file ( ../smee/$name.txt )

Quote Reply
Re: Deleting File Contents In reply to
NO you only use
$file = "myfile.txt";
open (LOG, ">$file");


Paul Wilson. Shocked
(Dont blame me if I'm wrong!)