This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Adjust executable suffix checks for VMS
[perl5.git] / pod / perlport.pod
index 2b4d3d9..a90d4cd 100644 (file)
@@ -453,30 +453,32 @@ Don't count on specific values of C<$!>.
 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)