write

write FILEHANDLE
writeThis function writes a formatted record (possibly multiline) to
the specified filehandle, using the format associated with that
filehandle—see the section Format Variables in Chapter 26. By default, the format associated with a
filehandle is the one having the same name as the filehandle. However,
the format for a filehandle may be changed by altering the $~ variable after you select that handle:
$old_fh = select(HANDLE); $~ = "NEWNAME"; select($old_fh);
or by saying:
use IO::Handle;
HANDLE–>format_name("NEWNAME");Since formats are put into a package namespace, you may have to
fully qualify the format name if the format was declared in a different
package:
$~ = "OtherPack::NEWNAME";
Top-of-form processing is handled automatically. If there is
insufficient room on the current page for the formatted record, the page
is advanced by writing a form feed, a special top-of-page format is used
for the new page header, and then the record is written. The number of
lines remaining on the current page is in the variable $–, which can be set to 0 to force a new page
on the next write. (You may need to
select the filehandle first.) By default, the name of the top-of-page ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access