perlfunc
gods
<P>
write - print a picture record
<P>
<HR>
<P>
write
<FONT SIZE=-1>FILEHANDLE</FONT>
<P>
write
<FONT SIZE=-1>EXPR</FONT>
<P>
write
<P>
<HR>
<P>
Writes a formatted record (possibly multi-line) to the specified
<FONT SIZE=-1>FILEHANDLE,</FONT> using the format associated with that
file. By default the format for a file is the one having the same name as
the filehandle, but the format for the current output channel (see the [perlfunc:select|select()] function) may be set explicitly by assigning the name of the format to the <CODE>$~</CODE> variable.
<P>
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 to format the new page header, and then the record is written. By default the top-of-page format is the name of the filehandle with
<FONT SIZE=-1>``_TOP''</FONT> appended, but it may be dynamically set to the format of your choice by assigning the name to the
<CODE>$^</CODE> variable while the filehandle is selected. The number of lines remaining on
the current page is in variable <CODE>$-</CODE>, which can be set to <CODE>0</CODE> to force a new page.
<P>
If
<FONT SIZE=-1>FILEHANDLE</FONT> is unspecified, output goes to the current default output channel, which starts out as
<FONT SIZE=-1>STDOUT</FONT> but may be changed by the
[perlfunc:select|select()] operator. If the
<FONT SIZE=-1>FILEHANDLE</FONT> is an
<FONT SIZE=-1>EXPR,</FONT> then the expression is evaluated and the resulting string is used to look up the name of the
<FONT SIZE=-1>FILEHANDLE</FONT> at run time. For more on formats, see
[perlman:perlform|the perlform manpage].
<P>
Note that write is <EM>NOT</EM> the opposite of [perlfunc:read|read()]. Unfortunately.
<HR>