Perl truncate Function
This function truncates (reduces) the size of the file specified by FILEHANDLE to the specified LENGTH (in bytes). Produces a fatal error if the function is not implemented on your system.
Following is the simple syntax for this function −
truncate FILEHANDLE, LENGTH
This function returns undef if the operation failed and 1 on success.
Following is the example code showing its basic usage, it will truncate file "test.txt" to zero length −
When above code is executed, it produces the following result −