--- name: truncate status: documented runtime: pp source: src/runtime/pp/io.rs --- ```{index} single: truncate; Perl built-in (pp runtime) ``` # truncate ## Synopsis ```perl truncate($fh, $length); # by open filehandle truncate('/path/to/file', $len); # by filename ``` ## Description Truncates a file to a specified length. Truncates the file identified by the first argument to at most LENGTH bytes. The first argument may be either an open filehandle or a filename string. When given a filename, the file is opened for writing just long enough to perform the truncation. Returns 1 on success, `undef` on failure (e.g. permissions, invalid filehandle). ## See also open, seek, tell