in reply to How do I pre-extend a file to a specified size

open FILEHANDLE, " +< filename" or die "Unable to open: $! \n"; truncate FILEHANDLE, $desired_length or print "Unable to truncate: $ +! \n";
truncate just sets the filesize of the file opened by handle to whatever you specify; you can use it to remove characters from file as well as increase the filesize.

Replies are listed 'Best First'.
Re: Answer: How do I pre-extend a file to a specified size
by Mr. Muskrat (Canon) on Aug 26, 2009 at 17:29 UTC

    Actually, setting the length greater than the actual file size is undefined behavior.