perl-5.38.0
print FILEHANDLE LIST
print FILEHANDLE
print LIST
print

Prints a string or a list of strings. Returns true if successful. FILEHANDLE may be a scalar variable containing the name of or a reference to the filehandle, thus introducing one level of indirection. (NOTE: If FILEHANDLE is a variable and the next token is a term, it may be misinterpreted as an operator unless you interpose a + or put parentheses around the arguments.) If FILEHANDLE is omitted, prints to the last selected (see select) output handle. If LIST is omitted, prints $_ to the currently selected output handle. To use FILEHANDLE alone to print the content of $_ to it, you must use a bareword filehandle like FH, not an indirect one like $fh. To set the default output handle to something other than STDOUT, use the select operation.

文字列か文字列のリストを出力します。 成功時には真を返します。 FILEHANDLE は、ファイルハンドル名またはそのリファレンスが 入っているスカラ変数名でもよいので、一段階の間接指定が行なえます。 (注: FILEHANDLE に変数を使い、次のトークンが「項」のときには、 間に + を置くか、引数の前後を括弧で括らなければ、 誤って解釈されることがあります。) FILEHANDLE を省略した場合には、最後に選択された (select 参照) 出力チャネルに出力します。 LIST を省略すると、$_ が現在選択されている出力ハンドルに 出力されます。 $_ の内容を表示するために FILEHANDLE のみを使用するには、 $fh のような間接ファイルハンドルではなく、FH のような裸の単語の ファイルハンドルを使わなければなりません。 デフォルトの出力チャネルを STDOUT 以外にするには、select 演算子を 使ってください。

The current value of $, (if any) is printed between each LIST item. The current value of $\ (if any) is printed after the entire LIST has been printed. Because print takes a LIST, anything in the LIST is evaluated in list context, including any subroutines whose return lists you pass to print. Be careful not to follow the print keyword with a left parenthesis unless you want the corresponding right parenthesis to terminate the arguments to the print; put parentheses around all arguments (or interpose a +, but that doesn't look as good).

$, の値が(もしあれば)各 LIST 要素の間に出力されます。 LIST 全体が出力された後、(もしあれば) $\ の現在の値が 出力されます。 print の引数は LIST なので、LIST の中のものは、すべてリストコンテキストで 評価されます; print に渡した、リストを返す サブルーチンも含みます。 また、すべての引数を括弧で括るのでなければ、print というキーワードの 次に開き括弧を書いてはいけません; すべての引数を括弧で括ってください (あるいは "print" と引数の間に + を書きますが、これはあまり よくありません)。

If you're storing handles in an array or hash, or in general whenever you're using any expression more complex than a bareword handle or a plain, unsubscripted scalar variable to retrieve it, you will have to use a block returning the filehandle value instead, in which case the LIST may not be omitted:

もし FILESHANDLE を配列、ハッシュあるいは一般的には裸の単語のハンドルや 普通のスカラ変数よりも複雑な表現を使っている場合、代わりにその値を返す ブロックを使う必要があります; この場合 LIST は省略できません:

    print { $files[$i] } "stuff\n";
    print { $OK ? *STDOUT : *STDERR } "stuff\n";

Printing to a closed pipe or socket will generate a SIGPIPE signal. See perlipc for more on signal handling.

閉じたパイプやソケットに print すると SIGPIPE シグナルが生成されます。 さらなるシグナル操作については perlipc を参照してください。