Copyright © tutorialspoint.com

PERL telldir Function


Syntax

truncate FILEHANDLE, LENGTH


Definition and Usage

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.

Return Value

  • undef if the operation failed

  • 1 on success

Example

Following example will truncate file "test.txt" to zero length.

#!/usr/bin/perl -w

open( FILE, "</tmp/test.txt" ) || die "Enable to open test file";

truncate( FILE, 0 );

close(FILE);

Copyright © tutorialspoint.com