truncate
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).
Synopsis
truncate($fh, $length); # by open filehandle
truncate('/path/to/file', $len); # by filename