Perldoc Search: "$^X" perl-5.20.1

search official POD

4 PODs, 13 LINEs found.
204 :                 system($^X, '-e',
339 :     $^X     The name used to execute the current copy of Perl, from C's "argv[0]" or (where supported) /proc/self/exe.
341 :             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.
343 :             You usually can use the value of $^X to re-invoke an independent copy of the same perl that is currently running, e.g.,
345 :                 @first_run = `$^X -le "print int rand 100 for 1..100"`;
349 :             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:
353 :                 my $this_perl = $^X;
359 :             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.
229 :     Don't assume that the name used to invoke a command or program with "system" or "exec" can also be used to test for the existence of the file that holds the executable code for that command or program. First, many systems have "internal" commands that are built-in to the shell or OS and while these commands can be invoked, there is no corresponding file. Second, some operating systems (e.g., Cygwin, DJGPP, OS/2, and VOS) have required suffixes for executable files; these suffixes are generally permitted on the command name but are not required. Thus, a command like "perl" might exist in a file named "perl", "perl.exe", or "", depending on the operating system. The variable "_exe" in the Config module holds the executable suffix, if any. Third, the VMS port carefully sets up $^X and $Config{perlpath} so that no further processing is required. This is just as well, because the matching regular expression used below would then have to deal with a possible trailing version number in the VMS file name.
231 :     To convert $^X to a file pathname, taking account of the requirements of the various operating system possibilities, say:
234 :      my $thisperl = $^X;
729 :      #define SAY_HELLO "-e", "print qq(Hi, I'm $^X\n)"
3355 :         (D deprecated) Using literal control characters in the source to refer to the ^FOO variables, like $^X and "${^GLOBAL_PHASE}" is now deprecated. This only affects code like "$\cT", where \cT is a control in the source code: "${"\cT"}" and $^T remain valid.
<< Back to Perldoc Search