home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _d39d3ab737074000e3884d21c04e1700 < prev    next >
Text File  |  2000-03-23  |  50KB  |  887 lines

  1. <HTML>
  2. <HEAD>
  3. <TITLE>perlvms - VMS-specific documentation for Perl</TITLE>
  4. <LINK REL="stylesheet" HREF="../../Active.css" TYPE="text/css">
  5. <LINK REV="made" HREF="mailto:">
  6. </HEAD>
  7.  
  8. <BODY>
  9. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  10. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  11. <STRONG><P CLASS=block> perlvms - VMS-specific documentation for Perl</P></STRONG>
  12. </TD></TR>
  13. </TABLE>
  14.  
  15. <A NAME="__index__"></A>
  16. <!-- INDEX BEGIN -->
  17.  
  18. <UL>
  19.  
  20.     <LI><A HREF="#name">NAME</A></LI>
  21.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  22.     <LI><A HREF="#installation">Installation</A></LI>
  23.     <LI><A HREF="#organization of perl images">Organization of Perl Images</A></LI>
  24.     <UL>
  25.  
  26.         <LI><A HREF="#core images">Core Images</A></LI>
  27.         <LI><A HREF="#perl extensions">Perl Extensions</A></LI>
  28.         <LI><A HREF="#installing static extensions">Installing static extensions</A></LI>
  29.         <LI><A HREF="#installing dynamic extensions">Installing dynamic extensions</A></LI>
  30.     </UL>
  31.  
  32.     <LI><A HREF="#file specifications">File specifications</A></LI>
  33.     <UL>
  34.  
  35.         <LI><A HREF="#syntax">Syntax</A></LI>
  36.         <LI><A HREF="#wildcard expansion">Wildcard expansion</A></LI>
  37.         <LI><A HREF="#pipes">Pipes</A></LI>
  38.     </UL>
  39.  
  40.     <LI><A HREF="#perl5lib and perllib">PERL5LIB and PERLLIB</A></LI>
  41.     <LI><A HREF="#command line">Command line</A></LI>
  42.     <UL>
  43.  
  44.         <LI><A HREF="#i/o redirection and backgrounding">I/O redirection and backgrounding</A></LI>
  45.         <LI><A HREF="#command line switches">Command line switches</A></LI>
  46.     </UL>
  47.  
  48.     <LI><A HREF="#perl functions">Perl functions</A></LI>
  49.     <LI><A HREF="#perl variables">Perl variables</A></LI>
  50.     <LI><A HREF="#standard modules with vmsspecific differences">Standard modules with VMS-specific differences</A></LI>
  51.     <UL>
  52.  
  53.         <LI><A HREF="#sdbm_file">SDBM_File</A></LI>
  54.     </UL>
  55.  
  56.     <LI><A HREF="#revision date">Revision date</A></LI>
  57.     <LI><A HREF="#author">AUTHOR</A></LI>
  58. </UL>
  59. <!-- INDEX END -->
  60.  
  61. <HR>
  62. <P>
  63. <H1><A NAME="name">NAME</A></H1>
  64. <P>perlvms - VMS-specific documentation for Perl</P>
  65. <P>
  66. <HR>
  67. <H1><A NAME="description">DESCRIPTION</A></H1>
  68. <P>Gathered below are notes describing details of Perl 5's 
  69. behavior on VMS.  They are a supplement to the regular Perl 5 
  70. documentation, so we have focussed on the ways in which Perl 
  71. 5 functions differently under VMS than it does under Unix, 
  72. and on the interactions between Perl and the rest of the 
  73. operating system.  We haven't tried to duplicate complete 
  74. descriptions of Perl features from the main Perl 
  75. documentation, which can be found in the <EM>[.pod]</EM> 
  76. subdirectory of the Perl distribution.</P>
  77. <P>We hope these notes will save you from confusion and lost 
  78. sleep when writing Perl scripts on VMS.  If you find we've 
  79. missed something you think should appear here, please don't 
  80. hesitate to drop a line to <A HREF="mailto:vmsperl@newman.upenn.edu.">vmsperl@newman.upenn.edu.</A></P>
  81. <P>
  82. <HR>
  83. <H1><A NAME="installation">Installation</A></H1>
  84. <P>Directions for building and installing Perl 5 can be found in 
  85. the file <EM>README.vms</EM> in the main source directory of the 
  86. Perl distribution..</P>
  87. <P>
  88. <HR>
  89. <H1><A NAME="organization of perl images">Organization of Perl Images</A></H1>
  90. <P>
  91. <H2><A NAME="core images">Core Images</A></H2>
  92. <P>During the installation process, three Perl images are produced.
  93. <EM>Miniperl.Exe</EM> is an executable image which contains all of
  94. the basic functionality of Perl, but cannot take advantage of
  95. Perl extensions.  It is used to generate several files needed
  96. to build the complete Perl and various extensions.  Once you've
  97. finished installing Perl, you can delete this image.</P>
  98. <P>Most of the complete Perl resides in the shareable image
  99. <EM>PerlShr.Exe</EM>, which provides a core to which the Perl executable
  100. image and all Perl extensions are linked.  You should place this
  101. image in <EM>Sys$Share</EM>, or define the logical name <EM>PerlShr</EM> to
  102. translate to the full file specification of this image.  It should
  103. be world readable.  (Remember that if a user has execute only access
  104. to <EM>PerlShr</EM>, VMS will treat it as if it were a privileged shareable
  105. image, and will therefore require all downstream shareable images to be
  106. INSTALLed, etc.)</P>
  107. <P>Finally, <EM>Perl.Exe</EM> is an executable image containing the main
  108. entry point for Perl, as well as some initialization code.  It
  109. should be placed in a public directory, and made world executable.
  110. In order to run Perl with command line arguments, you should
  111. define a foreign command to invoke this image.</P>
  112. <P>
  113. <H2><A NAME="perl extensions">Perl Extensions</A></H2>
  114. <P>Perl extensions are packages which provide both XS and Perl code
  115. to add new functionality to perl.  (XS is a meta-language which
  116. simplifies writing C code which interacts with Perl, see
  117. <A HREF="../../lib/Pod/perlxs.html">the perlxs manpage</A> for more details.)  The Perl code for an
  118. extension is treated like any other library module - it's
  119. made available in your script through the appropriate
  120. <A HREF="../../lib/Pod/perlfunc.html#item_use"><CODE>use</CODE></A> or <A HREF="../../lib/Pod/perlfunc.html#item_require"><CODE>require</CODE></A> statement, and usually defines a Perl
  121. package containing the extension.</P>
  122. <P>The portion of the extension provided by the XS code may be
  123. connected to the rest of Perl in either of two ways.  In the
  124. <STRONG>static</STRONG> configuration, the object code for the extension is
  125. linked directly into <EM>PerlShr.Exe</EM>, and is initialized whenever
  126. Perl is invoked.  In the <STRONG>dynamic</STRONG> configuration, the extension's
  127. machine code is placed into a separate shareable image, which is
  128. mapped by Perl's DynaLoader when the extension is <A HREF="../../lib/Pod/perlfunc.html#item_use"><CODE>use</CODE></A>d or
  129. <A HREF="../../lib/Pod/perlfunc.html#item_require"><CODE>require</CODE></A>d in your script.  This allows you to maintain the
  130. extension as a separate entity, at the cost of keeping track of the
  131. additional shareable image.  Most extensions can be set up as either
  132. static or dynamic.</P>
  133. <P>The source code for an extension usually resides in its own
  134. directory.  At least three files are generally provided:
  135. <EM>Extshortname</EM><EM>.xs</EM> (where <EM>Extshortname</EM> is the portion of
  136. the extension's name following the last <CODE>::</CODE>), containing
  137. the XS code, <EM>Extshortname</EM><EM>.pm</EM>, the Perl library module
  138. for the extension, and <EM>Makefile.PL</EM>, a Perl script which uses
  139. the <CODE>MakeMaker</CODE> library modules supplied with Perl to generate
  140. a <EM>Descrip.MMS</EM> file for the extension.</P>
  141. <P>
  142. <H2><A NAME="installing static extensions">Installing static extensions</A></H2>
  143. <P>Since static extensions are incorporated directly into
  144. <EM>PerlShr.Exe</EM>, you'll have to rebuild Perl to incorporate a
  145. new extension.  You should edit the main <EM>Descrip.MMS</EM> or <EM>Makefile</EM>
  146. you use to build Perl, adding the extension's name to the <CODE>ext</CODE>
  147. macro, and the extension's object file to the <CODE>extobj</CODE> macro.
  148. You'll also need to build the extension's object file, either
  149. by adding dependencies to the main <EM>Descrip.MMS</EM>, or using a
  150. separate <EM>Descrip.MMS</EM> for the extension.  Then, rebuild
  151. <EM>PerlShr.Exe</EM> to incorporate the new code.</P>
  152. <P>Finally, you'll need to copy the extension's Perl library
  153. module to the <EM>[.</EM><EM>Extname</EM><EM>]</EM> subdirectory under one
  154. of the directories in <CODE>@INC</CODE>, where <EM>Extname</EM> is the name
  155. of the extension, with all <CODE>::</CODE> replaced by <CODE>.</CODE> (e.g.
  156. the library module for extension Foo::Bar would be copied
  157. to a <EM>[.Foo.Bar]</EM> subdirectory).</P>
  158. <P>
  159. <H2><A NAME="installing dynamic extensions">Installing dynamic extensions</A></H2>
  160. <P>In general, the distributed kit for a Perl extension includes
  161. a file named Makefile.PL, which is a Perl program which is used
  162. to create a <EM>Descrip.MMS</EM> file which can be used to build and
  163. install the files required by the extension.  The kit should be
  164. unpacked into a directory tree <STRONG>not</STRONG> under the main Perl source
  165. directory, and the procedure for building the extension is simply</P>
  166. <PRE>
  167.     $ perl Makefile.PL  ! Create Descrip.MMS
  168.     $ mmk               ! Build necessary files
  169.     $ mmk test          ! Run test code, if supplied
  170.     $ mmk install       ! Install into public Perl tree</PRE>
  171. <P><EM>N.B.</EM> The procedure by which extensions are built and
  172. tested creates several levels (at least 4) under the
  173. directory in which the extension's source files live.
  174. For this reason, you shouldn't nest the source directory
  175. too deeply in your directory structure, lest you eccedd RMS'
  176. maximum of 8 levels of subdirectory in a filespec.  (You
  177. can use rooted logical names to get another 8 levels of
  178. nesting, if you can't place the files near the top of
  179. the physical directory structure.)</P>
  180. <P>VMS support for this process in the current release of Perl
  181. is sufficient to handle most extensions.  However, it does
  182. not yet recognize extra libraries required to build shareable
  183. images which are part of an extension, so these must be added
  184. to the linker options file for the extension by hand.  For
  185. instance, if the <EM>PGPLOT</EM> extension to Perl requires the
  186. <EM>PGPLOTSHR.EXE</EM> shareable image in order to properly link
  187. the Perl extension, then the line <CODE>PGPLOTSHR/Share</CODE> must
  188. be added to the linker options file <EM>PGPLOT.Opt</EM> produced
  189. during the build process for the Perl extension.</P>
  190. <P>By default, the shareable image for an extension is placed
  191. <EM>[.lib.site_perl.auto</EM><EM>Arch</EM>.<EM>Extname</EM><EM>]</EM> directory of the
  192. installed Perl directory tree (where <EM>Arch</EM> is <EM>VMS_VAX</EM> or
  193. <EM>VMS_AXP</EM>, and <EM>Extname</EM> is the name of the extension, with
  194. each <CODE>::</CODE> translated to <CODE>.</CODE>).  (See the MakeMaker documentation
  195. for more details on installation options for extensions.)
  196. However, it can be manually placed in any of several locations:
  197.    - the <EM>[.Lib.Auto.</EM><EM>Arch</EM><EM>$PVers</EM><EM>Extname</EM><EM>]</EM> subdirectory
  198.      of one of the directories in <CODE>@INC</CODE> (where <EM>PVers</EM>
  199.      is the version of Perl you're using, as supplied in <CODE>$]</CODE>,
  200.      with '.' converted to '_'), or
  201.    - one of the directories in <CODE>@INC</CODE>, or
  202.    - a directory which the extensions Perl library module
  203.      passes to the DynaLoader when asking it to map
  204.      the shareable image, or
  205.    - <EM>Sys$Share</EM> or <EM>Sys$Library</EM>.
  206. If the shareable image isn't in any of these places, you'll need
  207. to define a logical name <EM>Extshortname</EM>, where <EM>Extshortname</EM>
  208. is the portion of the extension's name after the last <CODE>::</CODE>, which
  209. translates to the full file specification of the shareable image.</P>
  210. <P>
  211. <HR>
  212. <H1><A NAME="file specifications">File specifications</A></H1>
  213. <P>
  214. <H2><A NAME="syntax">Syntax</A></H2>
  215. <P>We have tried to make Perl aware of both VMS-style and Unix-
  216. style file specifications wherever possible.  You may use 
  217. either style, or both, on the command line and in scripts, 
  218. but you may not combine the two styles within a single fle 
  219. specification.  VMS Perl interprets Unix pathnames in much
  220. the same way as the CRTL (<EM>e.g.</EM> the first component of
  221. an absolute path is read as the device name for the
  222. VMS file specification).  There are a set of functions
  223. provided in the <CODE>VMS::Filespec</CODE> package for explicit
  224. interconversion between VMS and Unix syntax; its
  225. documentation provides more details.</P>
  226. <P>Filenames are, of course, still case-insensitive.  For
  227. consistency, most Perl routines return  filespecs using
  228. lower case letters only, regardless of the case used in
  229. the arguments passed to them.  (This is true  only when
  230. running under VMS; Perl respects the case-sensitivity
  231. of OSs like Unix.)</P>
  232. <P>We've tried to minimize the dependence of Perl library 
  233. modules on Unix syntax, but you may find that some of these, 
  234. as well as some scripts written for Unix systems, will 
  235. require that you use Unix syntax, since they will assume that 
  236. '/' is the directory separator, <EM>etc.</EM>  If you find instances 
  237. of this in the Perl distribution itself, please let us know, 
  238. so we can try to work around them.</P>
  239. <P>
  240. <H2><A NAME="wildcard expansion">Wildcard expansion</A></H2>
  241. <P>File specifications containing wildcards are allowed both on 
  242. the command line and within Perl globs (e.g. <C<*.c>>).  If
  243. the wildcard filespec uses VMS syntax, the resultant 
  244. filespecs will follow VMS syntax; if a Unix-style filespec is 
  245. passed in, Unix-style filespecs will be returned.</P>
  246. <P>In both cases, VMS wildcard expansion is performed. (csh-style
  247. wildcard expansion is available if you use <CODE>File::Glob::glob</CODE>.)
  248. If the wildcard filespec contains a device or directory 
  249. specification, then the resultant filespecs will also contain 
  250. a device and directory; otherwise, device and directory 
  251. information are removed.  VMS-style resultant filespecs will 
  252. contain a full device and directory, while Unix-style 
  253. resultant filespecs will contain only as much of a directory 
  254. path as was present in the input filespec.  For example, if 
  255. your default directory is Perl_Root:[000000], the expansion 
  256. of <CODE>[.t]*.*</CODE> will yield filespecs  like 
  257. ``perl_root:[t]base.dir'', while the expansion of <CODE>t/*/*</CODE> will 
  258. yield filespecs like ``t/base.dir''.  (This is done to match 
  259. the behavior of glob expansion performed by Unix shells.)</P>
  260. <P>Similarly, the resultant filespec will contain the file version
  261. only if one was present in the input filespec.</P>
  262. <P>
  263. <H2><A NAME="pipes">Pipes</A></H2>
  264. <P>Input and output pipes to Perl filehandles are supported; the 
  265. ``file name'' is passed to lib$spawn() for asynchronous 
  266. execution.  You should be careful to close any pipes you have 
  267. opened in a Perl script, lest you leave any ``orphaned'' 
  268. subprocesses around when Perl exits.</P>
  269. <P>You may also use backticks to invoke a DCL subprocess, whose 
  270. output is used as the return value of the expression.  The 
  271. string between the backticks is handled as if it were the
  272. argument to the <A HREF="#item_system"><CODE>system</CODE></A> operator (see below).  In this case,
  273. Perl will wait for the subprocess to complete before continuing.</P>
  274. <P>
  275. <HR>
  276. <H1><A NAME="perl5lib and perllib">PERL5LIB and PERLLIB</A></H1>
  277. <P>The PERL5LIB and PERLLIB logical names work as documented <A HREF="../../lib/Pod/perl.html">the perl manpage</A>,
  278. except that the element separator is '|' instead of ':'.  The
  279. directory specifications may use either VMS or Unix syntax.</P>
  280. <P>
  281. <HR>
  282. <H1><A NAME="command line">Command line</A></H1>
  283. <P>
  284. <H2><A NAME="i/o redirection and backgrounding">I/O redirection and backgrounding</A></H2>
  285. <P>Perl for VMS supports redirection of input and output on the 
  286. command line, using a subset of Bourne shell syntax:</P>
  287. <PRE>
  288.     <F<file> reads stdin from F<file>,
  289.     >F<file> writes stdout to F<file>,
  290.     >>F<file> appends stdout to F<file>,
  291.     2>F<file> writes stderr to F<file>, and
  292.     2>>F<file> appends stderr to F<file>.</PRE>
  293. <P>In addition, output may be piped to a subprocess, using the  
  294. character '|'.  Anything after this character on the command 
  295. line is passed to a subprocess for execution; the subprocess 
  296. takes the output of Perl as its input.</P>
  297. <P>Finally, if the command line ends with '&', the entire 
  298. command is run in the background as an asynchronous 
  299. subprocess.</P>
  300. <P>
  301. <H2><A NAME="command line switches">Command line switches</A></H2>
  302. <P>The following command line switches behave differently under
  303. VMS than described in <A HREF="../../lib/Pod/perlrun.html">the perlrun manpage</A>.  Note also that in order
  304. to pass uppercase switches to Perl, you need to enclose
  305. them in double-quotes on the command line, since the CRTL
  306. downcases all unquoted strings.</P>
  307. <DL>
  308. <DT><STRONG><A NAME="item_%2Di">-i</A></STRONG><BR>
  309. <DD>
  310. If the <A HREF="#item_%2Di"><CODE>-i</CODE></A> switch is present but no extension for a backup
  311. copy is given, then inplace editing creates a new version of
  312. a file; the existing copy is not deleted.  (Note that if
  313. an extension is given, an existing file is renamed to the backup
  314. file, as is the case under other operating systems, so it does
  315. not remain as a previous version under the original filename.)
  316. <P></P>
  317. <DT><STRONG><A NAME="item_%2DS">-S</A></STRONG><BR>
  318. <DD>
  319. If the <A HREF="#item_%2DS"><CODE>-S</CODE></A> switch is present <EM>and</EM> the script name does
  320. not contain a directory, then Perl translates the logical
  321. name DCL$PATH as a searchlist, using each translation as
  322. a directory in which to look for the script.  In addition,
  323. if no file type is specified, Perl looks in each directory
  324. for a file matching the name specified, with a blank type,
  325. a type of <EM>.pl</EM>, and a type of <EM>.com</EM>, in that order.
  326. <P></P>
  327. <DT><STRONG><A NAME="item_%2Du">-u</A></STRONG><BR>
  328. <DD>
  329. The <A HREF="#item_%2Du"><CODE>-u</CODE></A> switch causes the VMS debugger to be invoked
  330. after the Perl program is compiled, but before it has
  331. run.  It does not create a core dump file.
  332. <P></P></DL>
  333. <P>
  334. <HR>
  335. <H1><A NAME="perl functions">Perl functions</A></H1>
  336. <P>As of the time this document was last revised, the following 
  337. Perl functions were implemented in the VMS port of Perl 
  338. (functions marked with * are discussed in more detail below):</P>
  339. <PRE>
  340.     file tests*, abs, alarm, atan, backticks*, binmode*, bless,
  341.     caller, chdir, chmod, chown, chomp, chop, chr,
  342.     close, closedir, cos, crypt*, defined, delete,
  343.     die, do, dump*, each, endpwent, eof, eval, exec*,
  344.     exists, exit, exp, fileno, fork*, getc, getlogin,
  345.     getpwent*, getpwnam*, getpwuid*, glob, gmtime*, goto,
  346.     grep, hex, import, index, int, join, keys, kill*,
  347.     last, lc, lcfirst, length, local, localtime, log, m//,
  348.     map, mkdir, my, next, no, oct, open, opendir, ord, pack,
  349.     pipe, pop, pos, print, printf, push, q//, qq//, qw//,
  350.     qx//*, quotemeta, rand, read, readdir, redo, ref, rename,
  351.     require, reset, return, reverse, rewinddir, rindex,
  352.     rmdir, s///, scalar, seek, seekdir, select(internal),
  353.     select (system call)*, setpwent, shift, sin, sleep,
  354.     sort, splice, split, sprintf, sqrt, srand, stat,
  355.     study, substr, sysread, system*, syswrite, tell,
  356.     telldir, tie, time, times*, tr///, uc, ucfirst, umask,
  357.     undef, unlink*, unpack, untie, unshift, use, utime*,
  358.     values, vec, wait, waitpid*, wantarray, warn, write, y///</PRE>
  359. <P>The following functions were not implemented in the VMS port, 
  360. and calling them produces a fatal error (usually) or 
  361. undefined behavior (rarely, we hope):</P>
  362. <PRE>
  363.     chroot, dbmclose, dbmopen, fcntl, flock,
  364.     getpgrp, getppid, getpriority, getgrent, getgrgid,
  365.     getgrnam, setgrent, endgrent, ioctl, link, lstat,
  366.     msgctl, msgget, msgsend, msgrcv, readlink, semctl,
  367.     semget, semop, setpgrp, setpriority, shmctl, shmget,
  368.     shmread, shmwrite, socketpair, symlink, syscall</PRE>
  369. <P>The following functions are available on Perls compiled with Dec C 5.2 or
  370. greater and running VMS 7.0 or greater</P>
  371. <PRE>
  372.     truncate</PRE>
  373. <P>The following functions may or may not be implemented, 
  374. depending on what type of socket support you've built into 
  375. your copy of Perl:</P>
  376. <PRE>
  377.     accept, bind, connect, getpeername,
  378.     gethostbyname, getnetbyname, getprotobyname,
  379.     getservbyname, gethostbyaddr, getnetbyaddr,
  380.     getprotobynumber, getservbyport, gethostent,
  381.     getnetent, getprotoent, getservent, sethostent,
  382.     setnetent, setprotoent, setservent, endhostent,
  383.     endnetent, endprotoent, endservent, getsockname,
  384.     getsockopt, listen, recv, select(system call)*,
  385.     send, setsockopt, shutdown, socket</PRE>
  386. <DL>
  387. <DT><STRONG><A NAME="item_File_tests">File tests</A></STRONG><BR>
  388. <DD>
  389. The tests <CODE>-b</CODE>, <CODE>-B</CODE>, <CODE>-c</CODE>, <CODE>-C</CODE>, <CODE>-d</CODE>, <CODE>-e</CODE>, <CODE>-f</CODE>,
  390. <CODE>-o</CODE>, <CODE>-M</CODE>, <CODE>-s</CODE>, <A HREF="#item_%2DS"><CODE>-S</CODE></A>, <CODE>-t</CODE>, <CODE>-T</CODE>, and <CODE>-z</CODE> work as
  391. advertised.  The return values for <CODE>-r</CODE>, <CODE>-w</CODE>, and <CODE>-x</CODE>
  392. tell you whether you can actually access the file; this may
  393. not reflect the UIC-based file protections.  Since real and
  394. effective UIC don't differ under VMS, <CODE>-O</CODE>, <CODE>-R</CODE>, <CODE>-W</CODE>,
  395. and <CODE>-X</CODE> are equivalent to <CODE>-o</CODE>, <CODE>-r</CODE>, <CODE>-w</CODE>, and <CODE>-x</CODE>.
  396. Similarly, several other tests, including <CODE>-A</CODE>, <CODE>-g</CODE>, <CODE>-k</CODE>,
  397. <CODE>-l</CODE>, <CODE>-p</CODE>, and <A HREF="#item_%2Du"><CODE>-u</CODE></A>, aren't particularly meaningful under
  398. VMS, and the values returned by these tests reflect whatever
  399. your CRTL <A HREF="#item_stat"><CODE>stat()</CODE></A> routine does to the equivalent bits in the
  400. st_mode field.  Finally, <CODE>-d</CODE> returns true if passed a device
  401. specification without an explicit directory (e.g. <CODE>DUA1:</CODE>), as
  402. well as if passed a directory.
  403. <P>Note: Some sites have reported problems when using the file-access
  404. tests (<CODE>-r</CODE>, <CODE>-w</CODE>, and <CODE>-x</CODE>) on files accessed via DEC's DFS.
  405. Specifically, since DFS does not currently provide access to the
  406. extended file header of files on remote volumes, attempts to
  407. examine the ACL fail, and the file tests will return false,
  408. with <A HREF="#item_%24%21"><CODE>$!</CODE></A> indicating that the file does not exist.  You can
  409. use <A HREF="#item_stat"><CODE>stat</CODE></A> on these files, since that checks UIC-based protection
  410. only, and then manually check the appropriate bits, as defined by
  411. your C compiler's <EM>stat.h</EM>, in the mode value it returns, if you
  412. need an approximation of the file's protections.</P>
  413. <P></P>
  414. <DT><STRONG><A NAME="item_backticks">backticks</A></STRONG><BR>
  415. <DD>
  416. Backticks create a subprocess, and pass the enclosed string
  417. to it for execution as a DCL command.  Since the subprocess is
  418. created directly via <CODE>lib$spawn()</CODE>, any valid DCL command string
  419. may be specified.
  420. <P></P>
  421. <DT><STRONG><A NAME="item_binmode">binmode FILEHANDLE</A></STRONG><BR>
  422. <DD>
  423. The <A HREF="#item_binmode"><CODE>binmode</CODE></A> operator will attempt to insure that no translation
  424. of carriage control occurs on input from or output to this filehandle.
  425. Since this involves reopening the file and then restoring its
  426. file position indicator, if this function returns FALSE, the
  427. underlying filehandle may no longer point to an open file, or may
  428. point to a different position in the file than before <A HREF="#item_binmode"><CODE>binmode</CODE></A>
  429. was called.
  430. <P>Note that <A HREF="#item_binmode"><CODE>binmode</CODE></A> is generally not necessary when using normal
  431. filehandles; it is provided so that you can control I/O to existing
  432. record-structured files when necessary.  You can also use the
  433. <CODE>vmsfopen</CODE> function in the VMS::Stdio extension to gain finer
  434. control of I/O to files and devices with different record structures.</P>
  435. <P></P>
  436. <DT><STRONG><A NAME="item_crypt">crypt PLAINTEXT, USER</A></STRONG><BR>
  437. <DD>
  438. The <A HREF="#item_crypt"><CODE>crypt</CODE></A> operator uses the <CODE>sys$hash_password</CODE> system
  439. service to generate the hashed representation of PLAINTEXT.
  440. If USER is a valid username, the algorithm and salt values
  441. are taken from that user's UAF record.  If it is not, then
  442. the preferred algorithm and a salt of 0 are used.  The
  443. quadword encrypted value is returned as an 8-character string.
  444. <P>The value returned by <A HREF="#item_crypt"><CODE>crypt</CODE></A> may be compared against
  445. the encrypted password from the UAF returned by the <CODE>getpw*</CODE>
  446. functions, in order to authenticate users.  If you're
  447. going to do this, remember that the encrypted password in
  448. the UAF was generated using uppercase username and
  449. password strings; you'll have to upcase the arguments to
  450. <A HREF="#item_crypt"><CODE>crypt</CODE></A> to insure that you'll get the proper value:</P>
  451. <PRE>
  452.   sub validate_passwd {
  453.     my($user,$passwd) = @_;
  454.     my($pwdhash);
  455.     if ( !($pwdhash = (getpwnam($user))[1]) ||
  456.          $pwdhash ne crypt("\U$passwd","\U$name") ) {
  457.       intruder_alert($name);
  458.     }
  459.     return 1;
  460.   }</PRE>
  461. <P></P>
  462. <DT><STRONG><A NAME="item_dump">dump</A></STRONG><BR>
  463. <DD>
  464. Rather than causing Perl to abort and dump core, the <A HREF="#item_dump"><CODE>dump</CODE></A>
  465. operator invokes the VMS debugger.  If you continue to
  466. execute the Perl program under the debugger, control will
  467. be transferred to the label specified as the argument to
  468. <A HREF="#item_dump"><CODE>dump</CODE></A>, or, if no label was specified, back to the
  469. beginning of the program.  All other state of the program
  470. (<EM>e.g.</EM> values of variables, open file handles) are not
  471. affected by calling <A HREF="#item_dump"><CODE>dump</CODE></A>.
  472. <P></P>
  473. <DT><STRONG><A NAME="item_exec">exec LIST</A></STRONG><BR>
  474. <DD>
  475. The <A HREF="#item_exec"><CODE>exec</CODE></A> operator behaves in one of two different ways.  
  476. If called after a call to <A HREF="#item_fork"><CODE>fork</CODE></A>, it will invoke the CRTL 
  477. <CODE>execv()</CODE> routine, passing its arguments to the subprocess 
  478. created by <A HREF="#item_fork"><CODE>fork</CODE></A> for execution.  In this case, it is 
  479. subject to all limitations that affect <CODE>execv()</CODE>.  (In 
  480. particular, this usually means that the command executed in 
  481. the subprocess must be an image compiled from C source code, 
  482. and that your options for passing file descriptors and signal 
  483. handlers to the subprocess are limited.)
  484. <P>If the call to <A HREF="#item_exec"><CODE>exec</CODE></A> does not follow a call to <A HREF="#item_fork"><CODE>fork</CODE></A>, it 
  485. will cause Perl to exit, and to invoke the command given as 
  486. an argument to <A HREF="#item_exec"><CODE>exec</CODE></A> via <CODE>lib$do_command</CODE>.  If the argument 
  487. begins with '@' or '$' (other than as part of a filespec), then it 
  488. is executed as a DCL command.  Otherwise, the first token on 
  489. the command line is treated as the filespec of an image to 
  490. run, and an attempt is made to invoke it (using <EM>.Exe</EM> and 
  491. the process defaults to expand the filespec) and pass the 
  492. rest of <A HREF="#item_exec"><CODE>exec</CODE></A>'s argument to it as parameters.  If the token
  493. has no file type, and matches a file with null type, then an
  494. attempt is made to determine whether the file is an executable
  495. image which should be invoked using <CODE>MCR</CODE> or a text file which
  496. should be passed to DCL as a command procedure.</P>
  497. <P>You can use <A HREF="#item_exec"><CODE>exec</CODE></A> in both ways within the same script, as 
  498. long as you call <A HREF="#item_fork"><CODE>fork</CODE></A> and <A HREF="#item_exec"><CODE>exec</CODE></A> in pairs.  Perl
  499. keeps track of how many times <A HREF="#item_fork"><CODE>fork</CODE></A> and <A HREF="#item_exec"><CODE>exec</CODE></A> have been
  500. called, and will call the CRTL <CODE>execv()</CODE> routine if there have
  501. previously been more calls to <A HREF="#item_fork"><CODE>fork</CODE></A> than to <A HREF="#item_exec"><CODE>exec</CODE></A>.</P>
  502. <P></P>
  503. <DT><STRONG><A NAME="item_fork">fork</A></STRONG><BR>
  504. <DD>
  505. The <A HREF="#item_fork"><CODE>fork</CODE></A> operator works in the same way as the CRTL 
  506. <CODE>vfork()</CODE> routine, which is quite different under VMS than 
  507. under Unix.  Specifically, while <A HREF="#item_fork"><CODE>fork</CODE></A> returns 0 after it 
  508. is called and the subprocess PID after <A HREF="#item_exec"><CODE>exec</CODE></A> is called, in 
  509. both cases the thread of execution is within the parent 
  510. process, so there is no opportunity to perform operations in 
  511. the subprocess before calling <A HREF="#item_exec"><CODE>exec</CODE></A>.
  512. <P>In general, the use of <A HREF="#item_fork"><CODE>fork</CODE></A> and <A HREF="#item_exec"><CODE>exec</CODE></A> to create 
  513. subprocess is not recommended under VMS; wherever possible, 
  514. use the <A HREF="#item_system"><CODE>system</CODE></A> operator or piped filehandles instead.</P>
  515. <P></P>
  516. <DT><STRONG><A NAME="item_getpwent">getpwent</A></STRONG><BR>
  517. <DD>
  518. <DT><STRONG><A NAME="item_getpwnam">getpwnam</A></STRONG><BR>
  519. <DD>
  520. <DT><STRONG><A NAME="item_getpwuid">getpwuid</A></STRONG><BR>
  521. <DD>
  522. These operators obtain the information described in <A HREF="../../lib/Pod/perlfunc.html">the perlfunc manpage</A>,
  523. if you have the privileges necessary to retrieve the named user's
  524. UAF information via <CODE>sys$getuai</CODE>.  If not, then only the <CODE>$name</CODE>,
  525. <CODE>$uid</CODE>, and <CODE>$gid</CODE> items are returned.  The <CODE>$dir</CODE> item contains
  526. the login directory in VMS syntax, while the <CODE>$comment</CODE> item
  527. contains the login directory in Unix syntax. The <CODE>$gcos</CODE> item
  528. contains the owner field from the UAF record.  The <CODE>$quota</CODE>
  529. item is not used.
  530. <P></P>
  531. <DT><STRONG><A NAME="item_gmtime">gmtime</A></STRONG><BR>
  532. <DD>
  533. The <A HREF="#item_gmtime"><CODE>gmtime</CODE></A> operator will function properly if you have a
  534. working CRTL <A HREF="#item_gmtime"><CODE>gmtime()</CODE></A> routine, or if the logical name
  535. SYS$TIMEZONE_DIFFERENTIAL is defined as the number of seconds
  536. which must be added to UTC to yield local time.  (This logical
  537. name is defined automatically if you are running a version of
  538. VMS with built-in UTC support.)  If neither of these cases is
  539. true, a warning message is printed, and <A HREF="../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A> is returned.
  540. <P></P>
  541. <DT><STRONG><A NAME="item_kill">kill</A></STRONG><BR>
  542. <DD>
  543. In most cases, <A HREF="#item_kill"><CODE>kill</CODE></A> kill is implemented via the CRTL's <A HREF="#item_kill"><CODE>kill()</CODE></A>
  544. function, so it will behave according to that function's
  545. documentation.  If you send a SIGKILL, however, the $DELPRC system
  546. service is called directly.  This insures that the target
  547. process is actually deleted, if at all possible.  (The CRTL's <A HREF="#item_kill"><CODE>kill()</CODE></A>
  548. function is presently implemented via $FORCEX, which is ignored by
  549. supervisor-mode images like DCL.)
  550. <P>Also, negative signal values don't do anything special under
  551. VMS; they're just converted to the corresponding positive value.</P>
  552. <P></P>
  553. <DT><STRONG><A NAME="item_qx/">qx//</A></STRONG><BR>
  554. <DD>
  555. See the entry on <A HREF="#item_backticks"><CODE>backticks</CODE></A> above.
  556. <P></P>
  557. <DT><STRONG><A NAME="item_select">select (system call)</A></STRONG><BR>
  558. <DD>
  559. If Perl was not built with socket support, the system call
  560. version of <A HREF="#item_select"><CODE>select</CODE></A> is not available at all.  If socket
  561. support is present, then the system call version of
  562. <A HREF="#item_select"><CODE>select</CODE></A> functions only for file descriptors attached
  563. to sockets.  It will not provide information about regular
  564. files or pipes, since the CRTL <A HREF="#item_select"><CODE>select()</CODE></A> routine does not
  565. provide this functionality.
  566. <P></P>
  567. <DT><STRONG><A NAME="item_stat">stat EXPR</A></STRONG><BR>
  568. <DD>
  569. Since VMS keeps track of files according to a different scheme
  570. than Unix, it's not really possible to represent the file's ID
  571. in the <CODE>st_dev</CODE> and <CODE>st_ino</CODE> fields of a <CODE>struct stat</CODE>.  Perl
  572. tries its best, though, and the values it uses are pretty unlikely
  573. to be the same for two different files.  We can't guarantee this,
  574. though, so caveat scriptor.
  575. <P></P>
  576. <DT><STRONG><A NAME="item_system">system LIST</A></STRONG><BR>
  577. <DD>
  578. The <A HREF="#item_system"><CODE>system</CODE></A> operator creates a subprocess, and passes its 
  579. arguments to the subprocess for execution as a DCL command.  
  580. Since the subprocess is created directly via <CODE>lib$spawn()</CODE>, any 
  581. valid DCL command string may be specified.  If the string begins with
  582. '@', it is treated as a DCL command unconditionally.  Otherwise, if
  583. the first token contains a character used as a delimiter in file
  584. specification (e.g. <CODE>:</CODE> or <CODE>]</CODE>), an attempt is made to expand it
  585. using  a default type of <EM>.Exe</EM> and the process defaults, and if
  586. successful, the resulting file is invoked via <CODE>MCR</CODE>. This allows you
  587. to invoke an image directly simply by passing the file specification
  588. to <A HREF="#item_system"><CODE>system</CODE></A>, a common Unixish idiom.  If the token has no file type,
  589. and matches a file with null type, then an attempt is made to
  590. determine whether the file is an executable image which should be
  591. invoked using <CODE>MCR</CODE> or a text file which should be passed to DCL
  592. as a command procedure.
  593. <P>If LIST consists of the empty string, <A HREF="#item_system"><CODE>system</CODE></A> spawns an
  594. interactive DCL subprocess, in the same fashion as typiing
  595. <STRONG>SPAWN</STRONG> at the DCL prompt.</P>
  596. <P>Perl waits for the subprocess to complete before continuing
  597. execution in the current process.  As described in <A HREF="../../lib/Pod/perlfunc.html">the perlfunc manpage</A>,
  598. the return value of <A HREF="#item_system"><CODE>system</CODE></A> is a fake ``status'' which follows
  599. POSIX semantics; see the description of <A HREF="#item_%24%3F"><CODE>$?</CODE></A> in this document
  600. for more detail.  The actual VMS exit status of the subprocess
  601. is available in <A HREF="#item_%24%5ES"><CODE>$^S</CODE></A> (as long as you haven't used another Perl
  602. function that resets <A HREF="#item_%24%3F"><CODE>$?</CODE></A> and <A HREF="#item_%24%5ES"><CODE>$^S</CODE></A> in the meantime).</P>
  603. <P></P>
  604. <DT><STRONG><A NAME="item_time">time</A></STRONG><BR>
  605. <DD>
  606. The value returned by <A HREF="#item_time"><CODE>time</CODE></A> is the offset in seconds from
  607. 01-JAN-1970 00:00:00 (just like the CRTL's <A HREF="#item_times"><CODE>times()</CODE></A> routine), in order
  608. to make life easier for code coming in from the POSIX/Unix world.
  609. <P></P>
  610. <DT><STRONG><A NAME="item_times">times</A></STRONG><BR>
  611. <DD>
  612. The array returned by the <A HREF="#item_times"><CODE>times</CODE></A> operator is divided up 
  613. according to the same rules the CRTL <A HREF="#item_times"><CODE>times()</CODE></A> routine.  
  614. Therefore, the ``system time'' elements will always be 0, since 
  615. there is no difference between ``user time'' and ``system'' time 
  616. under VMS, and the time accumulated by subprocess may or may 
  617. not appear separately in the ``child time'' field, depending on 
  618. whether <A HREF="#item_times">times</A> keeps track of subprocesses separately.  Note
  619. especially that the VAXCRTL (at least) keeps track only of
  620. subprocesses spawned using <A HREF="#item_fork">fork</A> and <A HREF="#item_exec">exec</A>; it will not
  621. accumulate the times of suprocesses spawned via pipes, <A HREF="#item_system">system</A>,
  622. or backticks.
  623. <P></P>
  624. <DT><STRONG><A NAME="item_unlink">unlink LIST</A></STRONG><BR>
  625. <DD>
  626. <A HREF="#item_unlink"><CODE>unlink</CODE></A> will delete the highest version of a file only; in
  627. order to delete all versions, you need to say
  628.     1 while (unlink LIST);
  629. You may need to make this change to scripts written for a
  630. Unix system which expect that after a call to <A HREF="#item_unlink"><CODE>unlink</CODE></A>,
  631. no files with the names passed to <A HREF="#item_unlink"><CODE>unlink</CODE></A> will exist.
  632. (Note: This can be changed at compile time; if you
  633. <CODE>use Config</CODE> and <CODE>$Config{'d_unlink_all_versions'}</CODE> is
  634. <CODE>define</CODE>, then <A HREF="#item_unlink"><CODE>unlink</CODE></A> will delete all versions of a
  635. file on the first call.)
  636. <P><A HREF="#item_unlink"><CODE>unlink</CODE></A> will delete a file if at all possible, even if it
  637. requires changing file protection (though it won't try to
  638. change the protection of the parent directory).  You can tell
  639. whether you've got explicit delete access to a file by using the
  640. <CODE>VMS::Filespec::candelete</CODE> operator.  For instance, in order
  641. to delete only files to which you have delete access, you could
  642. say something like</P>
  643. <PRE>
  644.     sub safe_unlink {
  645.         my($file,$num);
  646.         foreach $file (@_) {
  647.             next unless VMS::Filespec::candelete($file);
  648.             $num += unlink $file;
  649.         }
  650.         $num;
  651.     }</PRE>
  652. <P>(or you could just use <CODE>VMS::Stdio::remove</CODE>, if you've installed
  653. the VMS::Stdio extension distributed with Perl). If <A HREF="#item_unlink"><CODE>unlink</CODE></A> has to
  654. change the file protection to delete the file, and you interrupt it
  655. in midstream, the file may be left intact, but with a changed ACL
  656. allowing you delete access.</P>
  657. <P></P>
  658. <DT><STRONG><A NAME="item_utime">utime LIST</A></STRONG><BR>
  659. <DD>
  660. Since ODS-2, the VMS file structure for disk files, does not keep
  661. track of access times, this operator changes only the modification
  662. time of the file (VMS revision date).
  663. <P></P>
  664. <DT><STRONG><A NAME="item_waitpid">waitpid PID,FLAGS</A></STRONG><BR>
  665. <DD>
  666. If PID is a subprocess started by a piped <A HREF="../../lib/open.html">the open manpage</A>, <A HREF="#item_waitpid"><CODE>waitpid</CODE></A>
  667. will wait for that subprocess, and return its final
  668. status value.  If PID is a subprocess created in some other way
  669. (e.g. SPAWNed before Perl was invoked), or is not a subprocess of
  670. the current process, <A HREF="#item_waitpid"><CODE>waitpid</CODE></A> will check once per second whether
  671. the process has completed, and when it has, will return 0.  (If PID
  672. specifies a process that isn't a subprocess of the current process,
  673. and you invoked Perl with the <CODE>-w</CODE> switch, a warning will be issued.)
  674. <P>The FLAGS argument is ignored in all cases.</P>
  675. <P></P></DL>
  676. <P>
  677. <HR>
  678. <H1><A NAME="perl variables">Perl variables</A></H1>
  679. <P>The following VMS-specific information applies to the indicated
  680. ``special'' Perl variables, in addition to the general information
  681. in <A HREF="../../lib/Pod/perlvar.html">the perlvar manpage</A>.  Where there is a conflict, this infrmation
  682. takes precedence.</P>
  683. <DL>
  684. <DT><STRONG><A NAME="item_%ENV">%ENV</A></STRONG><BR>
  685. <DD>
  686. The operation of the <A HREF="#item_%ENV"><CODE>%ENV</CODE></A> array depends on the translation
  687. of the logical name <EM>PERL_ENV_TABLES</EM>.  If defined, it should
  688. be a search list, each element of which specifies a location
  689. for <A HREF="#item_%ENV"><CODE>%ENV</CODE></A> elements.  If you tell Perl to read or set the
  690. element <CODE>$ENV{</CODE><EM>name</EM><CODE>}</CODE>, then Perl uses the translations of
  691. <EM>PERL_ENV_TABLES</EM> as follows:
  692. <DL>
  693. <DT><STRONG><A NAME="item_CRTL_ENV">CRTL_ENV</A></STRONG><BR>
  694. <DD>
  695. This string tells Perl to consult the CRTL's internal <CODE>environ</CODE>
  696. array of key-value pairs, using <EM>name</EM> as the key.  In most cases,
  697. this contains only a few keys, but if Perl was invoked via the C
  698. <CODE>exec[lv]e()</CODE> function, as is the case for CGI processing by some
  699. HTTP servers, then the <CODE>environ</CODE> array may have been populated by
  700. the calling program.
  701. <P></P>
  702. <DT><STRONG><A NAME="item_CLISYM_%5BLOCAL%5D">CLISYM_[LOCAL]</A></STRONG><BR>
  703. <DD>
  704. A string beginning with <CODE>CLISYM_</CODE>tells Perl to consult the CLI's
  705. symbol tables, using <EM>name</EM> as the name of the symbol.  When reading
  706. an element of <A HREF="#item_%ENV"><CODE>%ENV</CODE></A>, the local symbol table is scanned first, followed
  707. by the global symbol table..  The characters following <CODE>CLISYM_</CODE> are
  708. significant when an element of <A HREF="#item_%ENV"><CODE>%ENV</CODE></A> is set or deleted: if the
  709. complete string is <CODE>CLISYM_LOCAL</CODE>, the change is made in the local
  710. symbol table, otherwise the global symbol table is changed.
  711. <P></P>
  712. <DT><STRONG><A NAME="item_Any_other_string">Any other string</A></STRONG><BR>
  713. <DD>
  714. If an element of <EM>PERL_ENV_TABLES</EM> translates to any other string,
  715. that string is used as the name of a logical name table, which is
  716. consulted using <EM>name</EM> as the logical name.  The normal search
  717. order of access modes is used.
  718. <P></P></DL>
  719. <P><EM>PERL_ENV_TABLES</EM> is translated once when Perl starts up; any changes
  720. you make while Perl is running do not affect the behavior of <A HREF="#item_%ENV"><CODE>%ENV</CODE></A>.
  721. If <EM>PERL_ENV_TABLES</EM> is not defined, then Perl defaults to consulting
  722. first the logical name tables specified by <EM>LNM$FILE_DEV</EM>, and then
  723. the CRTL <CODE>environ</CODE> array.</P>
  724. <P>In all operations on %ENV, the key string is treated as if it 
  725. were entirely uppercase, regardless of the case actually 
  726. specified in the Perl expression.</P>
  727. <P>When an element of <A HREF="#item_%ENV"><CODE>%ENV</CODE></A> is read, the locations to which
  728. <EM>PERL_ENV_TABLES</EM> points are checked in order, and the value
  729. obtained from the first successful lookup is returned.  If the
  730. name of the <A HREF="#item_%ENV"><CODE>%ENV</CODE></A> element contains a semi-colon, it and
  731. any characters after it are removed.  These are ignored when
  732. the CRTL <CODE>environ</CODE> array or a CLI symbol table is consulted.
  733. However, the name is looked up in a logical name table, the
  734. suffix after the semi-colon is treated as the translation index
  735. to be used for the lookup.   This lets you look up successive values
  736. for search list logical names.  For instance, if you say</P>
  737. <PRE>
  738.    $  Define STORY  once,upon,a,time,there,was
  739.    $  perl -e "for ($i = 0; $i <= 6; $i++) " -
  740.    _$ -e "{ print $ENV{'story;'.$i},' '}"</PRE>
  741. <P>Perl will print <CODE>ONCE UPON A TIME THERE WAS</CODE>, assuming, of course,
  742. that <EM>PERL_ENV_TABLES</EM> is set up so that the logical name <CODE>story</CODE>
  743. is found, rather than a CLI symbol or CRTL <CODE>environ</CODE> element with
  744. the same name.</P>
  745. <P>When an element of <A HREF="#item_%ENV"><CODE>%ENV</CODE></A> is set to a defined string, the
  746. corresponding definition is made in the location to which the
  747. first translation of <EM>PERL_ENV_TABLES</EM> points.  If this causes a
  748. logical name to be created, it is defined in supervisor mode.
  749. (The same is done if an existing logical name was defined in
  750. executive or kernel mode; an existing user or supervisor mode
  751. logical name is reset to the new value.)  If the value is an empty
  752. string, the logical name's translation is defined as a single NUL
  753. (ASCII 00) character, since a logical name cannot translate to a
  754. zero-length string.  (This restriction does not apply to CLI symbols
  755. or CRTL <CODE>environ</CODE> values; they are set to the empty string.)
  756. An element of the CRTL <CODE>environ</CODE> array can be set only if your
  757. copy of Perl knows about the CRTL's <CODE>setenv()</CODE> function.  (This is
  758. present only in some versions of the DECCRTL; check <CODE>$Config{d_setenv}</CODE>
  759. to see whether your copy of Perl was built with a CRTL that has this
  760. function.)
  761. </P>
  762. <PRE>
  763.  
  764. When an element of C<%ENV> is set to C<undef>,
  765. the element is looked up as if it were being read, and if it is
  766. found, it is deleted.  (An item "deleted" from the CRTL C<environ>
  767. array is set to the empty string; this can only be done if your
  768. copy of Perl knows about the CRTL C<setenv()> function.)  Using
  769. C<delete> to remove an element from C<%ENV> has a similar effect,
  770. but after the element is deleted, another attempt is made to
  771. look up the element, so an inner-mode logical name or a name in
  772. another location will replace the logical name just deleted.
  773. In either case, only the first value found searching PERL_ENV_TABLES
  774. is altered.  It is not possible at present to define a search list
  775. logical name via %ENV.</PRE>
  776. <P>The element <CODE>$ENV{DEFAULT}</CODE> is special: when read, it returns
  777. Perl's current default device and directory, and when set, it
  778. resets them, regardless of the definition of <EM>PERL_ENV_TABLES</EM>.
  779. It cannot be cleared or deleted; attempts to do so are silently
  780. ignored.</P>
  781. <P>Note that if you want to pass on any elements of the
  782. C-local environ array to a subprocess which isn't
  783. started by fork/exec, or isn't running a C program, you
  784. can ``promote'' them to logical names in the current
  785. process, which will then be inherited by all subprocesses,
  786. by saying</P>
  787. <PRE>
  788.     foreach my $key (qw[C-local keys you want promoted]) {
  789.        my $temp = $ENV{$key}; # read from C-local array
  790.        $ENV{$key} = $temp;    # and define as logical name
  791.     }</PRE>
  792. <P>(You can't just say <CODE>$ENV{$key} = $ENV{$key}</CODE>, since the
  793. Perl optimizer is smart enough to elide the expression.)</P>
  794. <P>At present, the first time you iterate over %ENV using
  795. <A HREF="../../lib/Pod/perlfunc.html#item_keys"><CODE>keys</CODE></A>, or <A HREF="../../lib/Pod/perlfunc.html#item_values"><CODE>values</CODE></A>,  you will incur a time penalty as all
  796. logical names are read, in order to fully populate %ENV.
  797. Subsequent iterations will not reread logical names, so they
  798. won't be as slow, but they also won't reflect any changes
  799. to logical name tables caused by other programs.</P>
  800. <P>You do need to be careful with the logicals representing process-permanent
  801. files, such as <CODE>SYS$INPUT</CODE> and <CODE>SYS$OUTPUT</CODE>.  The translations for these
  802. logicals are prepended with a two-byte binary value (0x1B 0x00) that needs to be
  803. stripped off if you want to use it. (In previous versions of perl it wasn't
  804. possible to get the values of these logicals, as the null byte acted as an
  805. end-of-string marker)</P>
  806. <DT><STRONG><A NAME="item_%24%21">$!</A></STRONG><BR>
  807. <DD>
  808. The string value of <A HREF="#item_%24%21"><CODE>$!</CODE></A> is that returned by the CRTL's
  809. <CODE>strerror()</CODE> function, so it will include the VMS message for
  810. VMS-specific errors.  The numeric value of <A HREF="#item_%24%21"><CODE>$!</CODE></A> is the
  811. value of <CODE>errno</CODE>, except if errno is EVMSERR, in which
  812. case <A HREF="#item_%24%21"><CODE>$!</CODE></A> contains the value of vaxc$errno.  Setting <A HREF="#item_%24%21"><CODE>$!</CODE></A>
  813. always sets errno to the value specified.  If this value is
  814. EVMSERR, it also sets vaxc$errno to 4 (NONAME-F-NOMSG), so
  815. that the string value of <A HREF="#item_%24%21"><CODE>$!</CODE></A> won't reflect the VMS error
  816. message from before <A HREF="#item_%24%21"><CODE>$!</CODE></A> was set.
  817. <P></P>
  818. <DT><STRONG><A NAME="item_%24%5EE">$^E</A></STRONG><BR>
  819. <DD>
  820. This variable provides direct access to VMS status values
  821. in vaxc$errno, which are often more specific than the
  822. generic Unix-style error messages in <A HREF="#item_%24%21"><CODE>$!</CODE></A>.  Its numeric value
  823. is the value of vaxc$errno, and its string value is the
  824. corresponding VMS message string, as retrieved by sys$getmsg().
  825. Setting <A HREF="#item_%24%5EE"><CODE>$^E</CODE></A> sets vaxc$errno to the value specified.
  826. <P></P>
  827. <DT><STRONG><A NAME="item_%24%3F">$?</A></STRONG><BR>
  828. <DD>
  829. The ``status value'' returned in <A HREF="#item_%24%3F"><CODE>$?</CODE></A> is synthesized from the
  830. actual exit status of the subprocess in a way that approximates
  831. POSIX <A HREF="../../lib/Pod/perlfunc.html#item_wait"><CODE>wait(5)</CODE></A> semantics, in order to allow Perl programs to
  832. portably test for successful completion of subprocesses.  The
  833. low order 8 bits of <A HREF="#item_%24%3F"><CODE>$?</CODE></A> are always 0 under VMS, since the
  834. termination status of a process may or may not have been
  835. generated by an exception.  The next 8 bits are derived from
  836. severity portion of the subprocess' exit status: if the
  837. severity was success or informational, these bits are all 0;
  838. otherwise, they contain the severity value shifted left one bit.
  839. As a result, <A HREF="#item_%24%3F"><CODE>$?</CODE></A> will always be zero if the subprocess' exit
  840. status indicated successful completion, and non-zero if a
  841. warning or error occurred.  The actual VMS exit status may
  842. be found in <A HREF="#item_%24%5ES"><CODE>$^S</CODE></A> (q.v.).
  843. <P></P>
  844. <DT><STRONG><A NAME="item_%24%5ES">$^S</A></STRONG><BR>
  845. <DD>
  846. Under VMS, this is the 32-bit VMS status value returned by the
  847. last subprocess to complete.  Unlink <A HREF="#item_%24%3F"><CODE>$?</CODE></A>, no manipulation
  848. is done to make this look like a POSIX <A HREF="../../lib/Pod/perlfunc.html#item_wait"><CODE>wait(5)</CODE></A> value, so it
  849. may be treated as a normal VMS status value.
  850. <P></P>
  851. <DT><STRONG><A NAME="item_%24%7C">$|</A></STRONG><BR>
  852. <DD>
  853. Setting <A HREF="#item_%24%7C"><CODE>$|</CODE></A> for an I/O stream causes data to be flushed
  854. all the way to disk on each write (<EM>i.e.</EM> not just to
  855. the underlying RMS buffers for a file).  In other words,
  856. it's equivalent to calling <CODE>fflush()</CODE> and <CODE>fsync()</CODE> from C.
  857. <P></P></DL>
  858. <P>
  859. <HR>
  860. <H1><A NAME="standard modules with vmsspecific differences">Standard modules with VMS-specific differences</A></H1>
  861. <P>
  862. <H2><A NAME="sdbm_file">SDBM_File</A></H2>
  863. <P>SDBM_File works properly on VMS. It has, however, one minor
  864. difference. The database directory file created has a <EM>.sdbm_dir</EM>
  865. extension rather than a <EM>.dir</EM> extension. <EM>.dir</EM> files are VMS filesystem
  866. directory files, and using them for other purposes could cause unacceptable
  867. problems.</P>
  868. <P>
  869. <HR>
  870. <H1><A NAME="revision date">Revision date</A></H1>
  871. <P>This document was last updated on 26-Feb-2000, for Perl 5, 
  872. patchlevel 6.</P>
  873. <P>
  874. <HR>
  875. <H1><A NAME="author">AUTHOR</A></H1>
  876. <P>Charles Bailey  <<A HREF="mailto:bailey@cor.newman.upenn.edu">bailey@cor.newman.upenn.edu</A>>
  877. Dan Sugalski  <<A HREF="mailto:dan@sidhe.org">dan@sidhe.org</A>></P>
  878. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  879. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  880. <STRONG><P CLASS=block> perlvms - VMS-specific documentation for Perl</P></STRONG>
  881. </TD></TR>
  882. </TABLE>
  883.  
  884. </BODY>
  885.  
  886. </HTML>
  887.