Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Zeroing A File

by bluto (Curate)
on Mar 17, 2006 at 21:16 UTC ( #537580=note: print w/replies, xml ) Need Help??

in reply to Zeroing A File

What do you mean by "zero"? Truncate to zero length? Delete?

open my $fh, ">myfile"; # will truncate by opening it for write acces +s truncate "myfile", 0; # will truncate (if it's implemented on your +system) unlink "myfile"; # will remove it
FYI, under unix file ownership has little to do with being able to trucate or delete it. If you are root, you can do either. Otherwise, to truncate you'll need to have write access to the file. To delete it, you'll need write and execute access to the file's parent directory.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://537580]
[LanX]: Funny some weeks ago, I met people from the Cimbrian peninsula who didn't know it's called the Cimbrian peninsula ...
[LanX]: ... treid to make smalltalk and felt like Sheldon.
erix looks up Sheldon ...
[erix]: ah. well, that must feel nice, no? ;)
[erix]: not the best way to make friends, though (I suppose)
LanX Fun with Flags anyone?

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2018-03-22 18:49 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (283 votes). Check out past polls.