perl-5.38.0
$EXECUTABLE_NAME
$^X

The name used to execute the current copy of Perl, from C's argv[0] or (where supported) /proc/self/exe.

Perl バイナリ自身が実行された時の名前を C の argv[0] または (対応していれば) /proc/self/exe から持ってきたものです。

Depending on the host operating system, the value of $^X may be a relative or absolute pathname of the perl program file, or may be the string used to invoke perl but not the pathname of the perl program file. Also, most operating systems permit invoking programs that are not in the PATH environment variable, so there is no guarantee that the value of $^X is in PATH. For VMS, the value may or may not include a version number.

ホスト OS に依存して、$^X の値は perl プログラムファイルの絶対パスかも しれませんし、相対パスかもしれませんし、perl を起動するために使われる 文字列ではありますが perl プログラムファイルのパス名ではないかもしれません。 また、ほとんどの OS は PATH 環境変数にない位置のプログラムを起動することを 許しているので、$^X の値が PATH にある保証はありません。 VMS では、この値はバージョン番号を含む場合も含まない場合もあります。

You usually can use the value of $^X to re-invoke an independent copy of the same perl that is currently running, e.g.,

通常は、現在実行中のものと同じ perl の独立したコピーを再起動するために $^X の値を使えます; つまり:

    @first_run = `$^X -le "print int rand 100 for 1..100"`;

But recall that not all operating systems support forking or capturing of the output of commands, so this complex statement may not be portable.

しかし、全ての OS が fork やコマンドの出力の捕捉に対応しているわけでは ないので、この複雑な文は移植性がないかもしれないことを忘れないでください。

It is not safe to use the value of $^X as a path name of a file, as some operating systems that have a mandatory suffix on executable files do not require use of the suffix when invoking a command. To convert the value of $^X to a path name, use the following statements:

$^X の値をファイルのパス名として使うのは安全ではありません; 実行ファイルに 固定の接尾辞があり、コマンドの起動時には接尾辞が不要な OS もあるからです。 $^X の値をパス名に変換するには、以下のコードを使ってください:

    # Build up a set of file names (not command names).
    use Config;
    my $this_perl = $^X;
    if ($^O ne 'VMS') {
        $this_perl .= $Config{_exe}
        unless $this_perl =~ m/$Config{_exe}$/i;
    }
    # (コマンド名ではなく)ファイル名を構築する。
    use Config;
    my $this_perl = $^X;
    if ($^O ne 'VMS') {
        $this_perl .= $Config{_exe}
        unless $this_perl =~ m/$Config{_exe}$/i;
    }

Because many operating systems permit anyone with read access to the Perl program file to make a copy of it, patch the copy, and then execute the copy, the security-conscious Perl programmer should take care to invoke the installed copy of perl, not the copy referenced by $^X. The following statements accomplish this goal, and produce a pathname that can be invoked as a command or referenced as a file.

多くの OS が Perl のプログラムファイルのコピーを作って、コピーにパッチを当て、 それを実行するための読み込み権限を全員に与えているので、セキュリティ 意識のある Perl プログラマは $^X で参照されているコピーではなく、 インストールされている perl を起動するように気をつけるべきです。 以下のコードはこの目的を達成し、コマンドとして起動したりファイルとして 参照するためのパス名を作成します。

    use Config;
    my $secure_perl_path = $Config{perlpath};
    if ($^O ne 'VMS') {
        $secure_perl_path .= $Config{_exe}
        unless $secure_perl_path =~ m/$Config{_exe}$/i;
    }