Don't assume that the name used to invoke a command or program with
C<system> or C<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 operating systems have "internal" commands that are
-built-in to the OS and while these commands can be invoked, there is
-no corresponding file. Second, some operating systems (Cygwin, DJGPP,
-OS/2, and VOS) have required suffixes for executable files; these
-suffixes are generally permitted on the command name but are not
+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 "perl.pm", depending on the operating system.
The variable "_exe" in the Config module holds the executable suffix,
-if any. Third, VMS files always end in a version number, which comes
-after 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.
To convert $^X to a file pathname, taking account of the requirements
of the various operating system possibilities, say:
use Config;
- use File::Spec;
$thisperl = $^X;
- $thisperl .= $Config{_exe} unless $thisperl ~= m/$Config{_exe}([;\d]*)$/i;
+ if ($^O ne 'VMS')
+ {$thisperl .= $Config{_exe} unless $thisperl =~ m/$Config{_exe}$/i;}
To convert $Config{perlpath} to a file pathname, say:
-
use Config;
- use File::Spec;
- $thisperl = File::Spec->canonpath($Config{perlpath});
- $thisperl .= $Config{_exe} unless $thisperl ~= m/$Config{_exe}([;\d]*)$/i;
+ $thisperl = $Config{perlpath};
+ if ($^O ne 'VMS')
+ {$thisperl .= $Config{_exe} unless $thisperl =~ m/$Config{_exe}$/i;}
=head2 Interprocess Communication (IPC)
# Build up a set of file names (not command names).
use Config;
- use File::Spec;
- $this_perl = File::Spec->canonpath($^X);
- $this_perl .= $Config{_ext}
- unless $this_perl =~ m/$Config{_ext}([;\d]*)$/i;
+ $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
command or referenced as a file.
use Config;
- use File::Spec;
- $secure_perl_path = File::Spec->canonpath($Config{perlpath});
- $secure_perl_path .= $Config{_ext}
- unless $secure_perl_path =~ m/$Config{_ext}([;\d]*)$/i;
+ $secure_perl_path = $Config{perlpath};
+ if ($^O ne 'VMS')
+ {$secure_perl_path .= $Config{_exe}
+ unless $secure_perl_path =~ m/$Config{_exe}$/i;}
=item ARGV