Perl truncate Function


Advertisements


Description

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.

Syntax

Following is the simple syntax for this function −

truncate FILEHANDLE, LENGTH

Return Value

This function returns undef if the operation failed and 1 on success.

Example

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 −




Advertisements