Home > Archive > PERL CGI Beginners > August 2004 > How to Delete File Contents
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to Delete File Contents
|
|
| newzguy 2004-08-07, 3:55 am |
| How do I delete a file's content? I don't want it to
append, I want the contents overwritten, how do I
do it? What I have is:
# Append the fetched data to the local file.
open out, ">>$localfile";
print out $result->content;
close out;
Does the >> have something to do with appending?
thanks
| |
| A. Sinan Unur 2004-08-07, 3:55 am |
| newzguy@ziplip.com (newzguy) wrote in news:6d7814d4.0408061938.3856e8a4
@posting.google.com:
> How do I delete a file's content? I don't want it to
> append, I want the contents overwritten, how do I
> do it? What I have is:
>
> # Append the fetched data to the local file.
>
> open out, ">>$localfile";
open my $out, '>', $localfile or die "Cannot open $localfile: $!";
> print out $result->content;
> close out;
>
> Does the >> have something to do with appending?
perldoc -f open
| |
| Jürgen Exner 2004-08-07, 3:55 am |
| newzguy wrote:
> How do I delete a file's content?
Many different ways.
- you could delete the file and then recreate it; however coming to think of
it this would create new file although with the same file name.
- you could open the file for writing and immediately close it again
- ...
> I don't want it to
> append, I want the contents overwritten, how do I
> do it? What I have is:
>
> # Append the fetched data to the local file.
You don't want to append but you append?
Mind to explain?
> open out, ">>$localfile";
Ok, you code comforms with the comment, but both of those conflict with your
spec.
> print out $result->content;
> close out;
>
> Does the >> have something to do with appending?
What happened when you read the documentation for the open() function?
jue
|
|
|
|
|