Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: cleaning out a file

by turnstep (Parson)
on Apr 28, 2000 at 01:24 UTC ( [id://9480]=note: print w/replies, xml ) Need Help??


in reply to cleaning out a file

Nope.
But you could do this:
open(X, ">$filename");
or even:
perl -e "open(X, '>'.shift);" SYSTEM.DA0
which would shrink SYSTEM.DA0 to 0 bytes....

Replies are listed 'Best First'.
RE: Re: cleaning out a file
by perlmonkey (Hermit) on Apr 28, 2000 at 02:49 UTC
    Yes, I think this is the safest way. close FH if open FH, ">".$filename But overwrite mode might do an unlink/link combo. (meaning that the file $filename might be deleted, then recreated as a empty file). So this could be the same asunlink $filename; open ">$filename"; I am not sure. Anybody actually know if there is a difference? The file inode number should still be the same though for either method.
    Depending on what you are doing this is probably good enough.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://9480]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-09-14 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.