perl-5.38.0
write FILEHANDLE
write EXPR
write

Writes a formatted record (possibly multi-line) to the specified FILEHANDLE, 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 select function) may be set explicitly by assigning the name of the format to the $~ variable.

指定された FILEHANDLE に対して、そのファイルに対応させた フォーマットを使って、(複数行の場合もある) 整形された レコードを書き出します。 デフォルトでは、ファイルに対応するフォーマットは、ファイルハンドルと 同じ名前のものですが、その時点の出力チャネル (select 関数の項を 参照してください) のフォーマットは、その名前を明示的に変数 $~ に代入することで、変更が可能です。

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 and a special top-of-page format is used to format the new page header before the record is written. By default, the top-of-page format is the name of the filehandle with _TOP appended, or top in the current package if the former does not exist. This would be a problem with autovivified filehandles, but it may be dynamically set to the format of your choice by assigning the name to the $^ variable while that filehandle is selected. The number of lines remaining on the current page is in variable $-, which can be set to 0 to force a new page.

ページの先頭の処理は、自動的に行なわれます: 現在のページに整形された レコードを出力するだけのスペースがない場合には、改ページを行なってページを 進め、新しいページヘッダを整形するため、ページ先頭フォーマットが使われ、 その後でレコードが書かれます。 デフォルトでは、ページ先頭フォーマットは、ファイルハンドルの名前に _TOP をつなげたものか、前者が存在しないなら、現在のパッケージの top です。 これは自動有効化されたファイルハンドルで問題になる可能性がありますが、 ファイルハンドルが選択されている間に、 変数 $^ に名前を設定すれば、動的にフォーマットを 変更することができます。 そのページの残り行数は、変数 $- に入っており、この変数を 0 に設定することで、強制的に改ページを行なうことができます。

If FILEHANDLE is unspecified, output goes to the current default output channel, which starts out as STDOUT but may be changed by the select operator. If the FILEHANDLE is an EXPR, then the expression is evaluated and the resulting string is used to look up the name of the FILEHANDLE at run time. For more on formats, see perlform.

FILEHANDLE を指定しないと、出力はその時点のデフォルト出力チャネルに対して 行なわれます; これは、スクリプトの開始時点では STDOUT ですが、 select 演算子で変更することができます。 FILEHANDLE が EXPR ならば、式が評価され、その結果の文字列が 実行時に FILEHANDLE の名前として見られます。 フォーマットについて、さらには、perlform を参照してください。

Note that write is not the opposite of read. Unfortunately.

write は read の 反対のことをするもの ではありません。 残念ながら。