perl-5.38.0
$PROGRAM_NAME
$0

Contains the name of the program being executed.

実行されているプログラムの名前を示します。

On some (but not all) operating systems assigning to $0 modifies the argument area that the ps program sees. On some platforms you may have to use special ps options or a different ps to see the changes. Modifying the $0 is more useful as a way of indicating the current program state than it is for hiding the program you're running.

一部の(しかし全てではありません)オペレーティングシステムでは $0 に代入を行なうことで ps プログラムが見る引数エリアを修正します。 プラットフォームによっては、この変更を見るために 特殊な ps オプションや、 他の ps を使う必要があるものもあります。 $0 の修正は、実行しているプログラムを隠すよりは、 実行中のプログラムの状態を表示するときに、使うとよいでしょう。

Note that there are platform-specific limitations on the maximum length of $0. In the most extreme case it may be limited to the space occupied by the original $0.

$0 の最大長にはプラットフォーム固有の制限があることに注意してください。 最も極端な場合では、元の $0 で占められているサイズに制限されます。

In some platforms there may be arbitrary amount of padding, for example space characters, after the modified name as shown by ps. In some platforms this padding may extend all the way to the original length of the argument area, no matter what you do (this is the case for example with Linux 2.2).

プラットフォームによっては、任意の量のパッディングがある場合があります; 例えば、ps で見られる修正された名前の後の空白文字です。 プラットフォームによっては、このパッディングは、あなたが何をしたかに 関わらず、元の引数のエリア全体に拡張されるものもあります (例えば、これは Linux 2.2 の場合です)。

Note for BSD users: setting $0 does not completely remove "perl" from the ps(1) output. For example, setting $0 to "foobar" may result in "perl: foobar (perl)" (whether both the "perl: " prefix and the " (perl)" suffix are shown depends on your exact BSD variant and version). This is an operating system feature, Perl cannot help it.

BSD ユーザーへの注意: $0 に値をセットしても、ps(1) の出力から 完全に "perl" の文字列は取り除かれません。 例えば、$0"foobar" と設定すると、"perl: foobar (perl)" という 結果になります ("perl: " 接頭辞と" (perl)" 接尾辞が表示されるかどうかは 、正確な BSD の種類とバージョンに依存します)。 これはオペレーティングシステムの機能で、Perl は何もできません。

In multithreaded scripts Perl coordinates the threads so that any thread may modify its copy of the $0 and the change becomes visible to ps(1) (assuming the operating system plays along). Note that the view of $0 the other threads have will not change since they have their own copies of it.

マルチスレッドスクリプトでは、どのスレッドも自身の $0 のコピーを 変更できて、その変更が(OS が対応しているとして) ps(1) で見えるように、 Perl がスレッドを調整します。 他のスレッドが持っている $0 の見え方は(各自が自身のコピーを 持っているので)変わらないことに注意してください。

If the program has been given to perl via the switches -e or -E, $0 will contain the string "-e".

プログラムが perl に -e または -E オプション経由で与えられた場合、 $0 には文字列 "-e" を含みます。

On Linux as of perl v5.14.0 the legacy process name will be set with prctl(2), in addition to altering the POSIX name via argv[0] as perl has done since version 4.000. Now system utilities that read the legacy process name such as ps, top and killall will recognize the name you set when assigning to $0. The string you supply will be cut off at 16 bytes, this is a limitation imposed by Linux.

Linux では perl v5.14.0 以降、perl がバージョン 4.000 以降行っていた argv[0] 経由での POSIX 名の置き換えに加えて、 レガシープロセス名は prctl(2) で設定されます。 今では ps, top, killall のようにレガシープロセス名を読むユーティリティは $0 に代入することに設定される名前を認識します。 指定した文字列は 16 バイトに切り詰められます; これは Linux による 制限です。

Wide characters are invalid in $0 values. For historical reasons, though, Perl accepts them and encodes them to UTF-8. When this happens a wide-character warning is triggered.

ワイド文字は $0 の値としては不正です。 しかし、歴史的な理由により、Perl はこれを受け入れて、UTF-8 に エンコードします。 これが起きると、wide-character 警告が引き起こされます。

Mnemonic: same as sh and ksh.

記憶法: shksh と同じ。