threads::shared::queue and semaphore become Thread::Semaphore
[p5sagit/p5-mst-13.2.git] / pod / perlvar.pod
index a42f8c6..0672c4e 100644 (file)
@@ -663,8 +663,11 @@ Also see L<Error Indicators>.
 
 =item ${^ENCODING}
 
-The encoding used to interpret native eight-bit encodings to Unicode,
-see L<encode>.  An opaque C<Encode::XS> object.
+The I<object reference> to the Encode object that is used to convert
+the source code to Unicode.  Thanks to this variable your perl script
+does not have to be written in UTF-8.  Default is I<undef>.  The direct
+manipulation of this variable is highly discouraged.  See L<encoding>
+for more details.
 
 =item $OS_ERROR
 
@@ -1000,11 +1003,17 @@ built, as determined during the configuration process.  The value
 is identical to C<$Config{'osname'}>.  See also L<Config> and the 
 B<-V> command-line switch documented in L<perlrun>.
 
+In Windows platforms, $^O is not very helpful: since it is always
+C<MSWin32>, it doesn't tell the difference between
+95/98/ME/NT/2000/XP/CE/.NET.  Use Win32::GetOSName() or
+Win32::GetOSVersion() (see L<Win32> and L<perlport>) to distinguish
+between the variants.
+
 =item ${^OPEN}
 
 An internal variable used by PerlIO.  A string in two parts, separated
-by a C<\0> byte, the first part is the input disciplines, the second
-part is the output disciplines.
+by a C<\0> byte, the first part describes the input layers, the second
+part describes the output layers.
 
 =item $PERLDB
 
@@ -1147,8 +1156,52 @@ lexical scope.  See L<bytes>.
 
 =item $^X
 
-The name that the Perl binary itself was executed as, from C's C<argv[0]>.
-This may not be a full pathname, nor even necessarily in your path.
+The name used to execute the current copy of Perl, from C's
+C<argv[0]>.
+
+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.
+
+You usually can use the value of $^X to re-invoke an independent
+copy of the same perl that is currently running, e.g.,
+
+  @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.
+
+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:
+
+# Build up a set of file names (not command names).
+  use Config;
+  $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.
+
+  use Config;
+  $secure_perl_path = $Config{perlpath};
+  if ($^O ne 'VMS')
+     {$secure_perl_path .= $Config{_exe}
+          unless $secure_perl_path =~ m/$Config{_exe}$/i;}
 
 =item ARGV