Sunday 3 November 2019

perl empty the file content

Method 1:

open $filename, '>', 'file.txt';


Method 2:

truncate 'file.txt', 0;


Method 3:

`perl -pi -e 's/.*//s' file.txt`;


Method 4:

system(": > file.txt");


Method 5:

system(" > file.txt");


Method 6:

readpipe("cat /dev/null > file.txt");


Method 7:

readpipe("cp /dev/null file.txt");


0 Comments:

Post a Comment

Note: only a member of this blog may post a comment.

<< Home