Debian Codegraph @

upstream/opensuse-tumbleweed/man1/perlvms.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "PERLVMS 1"
61 .TH PERLVMS 1 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 perlvms \- VMS\-specific documentation for Perl
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 Gathered below are notes describing details of Perl 5\*(Aqs
71 behavior on VMS. They are a supplement to the regular Perl 5
72 documentation, so we have focussed on the ways in which Perl
73 5 functions differently under VMS than it does under Unix,
74 and on the interactions between Perl and the rest of the
75 operating system. We haven\*(Aqt tried to duplicate complete
76 descriptions of Perl features from the main Perl
77 documentation, which can be found in the \fI[.pod]\fR
78 subdirectory of the Perl distribution.
79 .PP
80 We hope these notes will save you from confusion and lost
81 sleep when writing Perl scripts on VMS. If you find we\*(Aqve
82 missed something you think should appear here, please don\*(Aqt
83 hesitate to drop a line to [email protected].
84 .SH Installation
85 .IX Header "Installation"
86 Directions for building and installing Perl 5 can be found in
87 the file \fIREADME.vms\fR in the main source directory of the
88 Perl distribution.
89 .SH "Organization of Perl Images"
90 .IX Header "Organization of Perl Images"
91 .SS "Core Images"
92 .IX Subsection "Core Images"
93 During the build process, three Perl images are produced.
94 \&\fIMiniperl.Exe\fR is an executable image which contains all of
95 the basic functionality of Perl, but cannot take advantage of
96 Perl XS extensions and has a hard\-wired list of library locations
97 for loading pure\-Perl modules. It is used extensively to build and
98 test Perl and various extensions, but is not installed.
99 .PP
100 Most of the complete Perl resides in the shareable image \fIPerlShr.Exe\fR,
101 which provides a core to which the Perl executable image and all Perl
102 extensions are linked. It is generally located via the logical name
103 \&\fIPERLSHR\fR. While it\*(Aqs possible to put the image in \fISYS$SHARE\fR to
104 make it loadable, that\*(Aqs not recommended. And while you may wish to
105 INSTALL the image for performance reasons, you should not install it
106 with privileges; if you do, the result will not be what you expect as
107 image privileges are disabled during Perl start\-up.
108 .PP
109 Finally, \fIPerl.Exe\fR is an executable image containing the main
110 entry point for Perl, as well as some initialization code. It
111 should be placed in a public directory, and made world executable.
112 In order to run Perl with command line arguments, you should
113 define a foreign command to invoke this image.
114 .SS "Perl Extensions"
115 .IX Subsection "Perl Extensions"
116 Perl extensions are packages which provide both XS and Perl code
117 to add new functionality to perl. (XS is a meta\-language which
118 simplifies writing C code which interacts with Perl, see
119 perlxs for more details.) The Perl code for an
120 extension is treated like any other library module \- it\*(Aqs
121 made available in your script through the appropriate
122 \&\f(CW\*(C`use\*(C'\fR or \f(CW\*(C`require\*(C'\fR statement, and usually defines a Perl
123 package containing the extension.
124 .PP
125 The portion of the extension provided by the XS code may be
126 connected to the rest of Perl in either of two ways. In the
127 \&\fBstatic\fR configuration, the object code for the extension is
128 linked directly into \fIPerlShr.Exe\fR, and is initialized whenever
129 Perl is invoked. In the \fBdynamic\fR configuration, the extension\*(Aqs
130 machine code is placed into a separate shareable image, which is
131 mapped by Perl\*(Aqs DynaLoader when the extension is \f(CW\*(C`use\*(C'\fRd or
132 \&\f(CW\*(C`require\*(C'\fRd in your script. This allows you to maintain the
133 extension as a separate entity, at the cost of keeping track of the
134 additional shareable image. Most extensions can be set up as either
135 static or dynamic.
136 .PP
137 The source code for an extension usually resides in its own
138 directory. At least three files are generally provided:
139 \&\fIExtshortname\fR\fI.xs\fR (where \fIExtshortname\fR is the portion of
140 the extension\*(Aqs name following the last \f(CW\*(C`::\*(C'\fR), containing
141 the XS code, \fIExtshortname\fR\fI.pm\fR, the Perl library module
142 for the extension, and \fIMakefile.PL\fR, a Perl script which uses
143 the \f(CW\*(C`MakeMaker\*(C'\fR library modules supplied with Perl to generate
144 a \fIDescrip.MMS\fR file for the extension.
145 .SS "Installing static extensions"
146 .IX Subsection "Installing static extensions"
147 Since static extensions are incorporated directly into
148 \&\fIPerlShr.Exe\fR, you\*(Aqll have to rebuild Perl to incorporate a
149 new extension. You should edit the main \fIDescrip.MMS\fR or \fIMakefile\fR
150 you use to build Perl, adding the extension\*(Aqs name to the \f(CW\*(C`ext\*(C'\fR
151 macro, and the extension\*(Aqs object file to the \f(CW\*(C`extobj\*(C'\fR macro.
152 You\*(Aqll also need to build the extension\*(Aqs object file, either
153 by adding dependencies to the main \fIDescrip.MMS\fR, or using a
154 separate \fIDescrip.MMS\fR for the extension. Then, rebuild
155 \&\fIPerlShr.Exe\fR to incorporate the new code.
156 .PP
157 Finally, you\*(Aqll need to copy the extension\*(Aqs Perl library
158 module to the \fI[.\fR\fIExtname\fR\fI]\fR subdirectory under one
159 of the directories in \f(CW@INC\fR, where \fIExtname\fR is the name
160 of the extension, with all \f(CW\*(C`::\*(C'\fR replaced by \f(CW\*(C`.\*(C'\fR (e.g.
161 the library module for extension Foo::Bar would be copied
162 to a \fI[.Foo.Bar]\fR subdirectory).
163 .SS "Installing dynamic extensions"
164 .IX Subsection "Installing dynamic extensions"
165 In general, the distributed kit for a Perl extension includes
166 a file named Makefile.PL, which is a Perl program which is used
167 to create a \fIDescrip.MMS\fR file which can be used to build and
168 install the files required by the extension. The kit should be
169 unpacked into a directory tree \fBnot\fR under the main Perl source
170 directory, and the procedure for building the extension is simply
171 .PP
172 .Vb 4
173 \& $ perl Makefile.PL ! Create Descrip.MMS
174 \& $ mmk ! Build necessary files
175 \& $ mmk test ! Run test code, if supplied
176 \& $ mmk install ! Install into public Perl tree
177 .Ve
178 .PP
179 VMS support for this process in the current release of Perl
180 is sufficient to handle most extensions. (See the MakeMaker
181 documentation for more details on installation options for
182 extensions.)
183 .IP \(bu 4
184 the \fI[.Lib.Auto.\fR\fIArch\fR\f(CI$PVers\fR\fI\fR\fIExtname\fR\fI]\fR subdirectory
185 of one of the directories in \f(CW@INC\fR (where \fIPVers\fR
186 is the version of Perl you\*(Aqre using, as supplied in \f(CW$]\fR,
187 with \*(Aq.\*(Aq converted to \*(Aq_\*(Aq), or
188 .IP \(bu 4
189 one of the directories in \f(CW@INC\fR, or
190 .IP \(bu 4
191 a directory which the extensions Perl library module
192 passes to the DynaLoader when asking it to map
193 the shareable image, or
194 .IP \(bu 4
195 \&\fISys$Share\fR or \fISys$Library\fR.
196 .PP
197 If the shareable image isn\*(Aqt in any of these places, you\*(Aqll need
198 to define a logical name \fIExtshortname\fR, where \fIExtshortname\fR
199 is the portion of the extension\*(Aqs name after the last \f(CW\*(C`::\*(C'\fR, which
200 translates to the full file specification of the shareable image.
201 .SH "File specifications"
202 .IX Header "File specifications"
203 .SS Syntax
204 .IX Subsection "Syntax"
205 We have tried to make Perl aware of both VMS\-style and Unix\-style file
206 specifications wherever possible. You may use either style, or both,
207 on the command line and in scripts, but you may not combine the two
208 styles within a single file specification. VMS Perl interprets Unix
209 pathnames in much the same way as the CRTL (\fIe.g.\fR the first component
210 of an absolute path is read as the device name for the VMS file
211 specification). There are a set of functions provided in the
212 \&\f(CW\*(C`VMS::Filespec\*(C'\fR package for explicit interconversion between VMS and
213 Unix syntax; its documentation provides more details.
214 .PP
215 We\*(Aqve tried to minimize the dependence of Perl library
216 modules on Unix syntax, but you may find that some of these,
217 as well as some scripts written for Unix systems, will
218 require that you use Unix syntax, since they will assume that
219 \&\*(Aq/\*(Aq is the directory separator, \fIetc.\fR If you find instances
220 of this in the Perl distribution itself, please let us know,
221 so we can try to work around them.
222 .PP
223 Also when working on Perl programs on VMS, if you need a syntax
224 in a specific operating system format, then you need either to
225 check the appropriate DECC$ feature logical, or call a conversion
226 routine to force it to that format.
227 .PP
228 The feature logical name DECC$FILENAME_UNIX_REPORT modifies traditional
229 Perl behavior in the conversion of file specifications from Unix to VMS
230 format in order to follow the extended character handling rules now
231 expected by the CRTL. Specifically, when this feature is in effect, the
232 \&\f(CW\*(C`./.../\*(C'\fR in a Unix path is now translated to \f(CW\*(C`[.^.^.^.]\*(C'\fR instead of
233 the traditional VMS \f(CW\*(C`[...]\*(C'\fR. To be compatible with what MakeMaker
234 expects, if a VMS path cannot be translated to a Unix path, it is
235 passed through unchanged, so \f(CWunixify("[...]")\fR will return \f(CW\*(C`[...]\*(C'\fR.
236 .PP
237 There are several ambiguous cases where a conversion routine cannot
238 determine whether an input filename is in Unix format or in VMS format,
239 since now both VMS and Unix file specifications may have characters in
240 them that could be mistaken for syntax delimiters of the other type. So
241 some pathnames simply cannot be used in a mode that allows either type
242 of pathname to be present. Perl will tend to assume that an ambiguous
243 filename is in Unix format.
244 .PP
245 Allowing "." as a version delimiter is simply incompatible with
246 determining whether a pathname is in VMS format or in Unix format with
247 extended file syntax. There is no way to know whether "perl\-5.8.6" is a
248 Unix "perl\-5.8.6" or a VMS "perl\-5.8;6" when passing it to \fBunixify()\fR or
249 \&\fBvmsify()\fR.
250 .PP
251 The DECC$FILENAME_UNIX_REPORT logical name controls how Perl interprets
252 filenames to the extent that Perl uses the CRTL internally for many
253 purposes, and attempts to follow CRTL conventions for reporting
254 filenames. The DECC$FILENAME_UNIX_ONLY feature differs in that it
255 expects all filenames passed to the C run\-time to be already in Unix
256 format. This feature is not yet supported in Perl since Perl uses
257 traditional OpenVMS file specifications internally and in the test
258 harness, and it is not yet clear whether this mode will be useful or
259 useable. The feature logical name DECC$POSIX_COMPLIANT_PATHNAMES is new
260 with the RMS Symbolic Link SDK and included with OpenVMS v8.3, but is
261 not yet supported in Perl.
262 .SS "Filename Case"
263 .IX Subsection "Filename Case"
264 Perl enables DECC$EFS_CASE_PRESERVE and DECC$ARGV_PARSE_STYLE by
265 default. Note that the latter only takes effect when extended parse
266 is set in the process in which Perl is running. When these features
267 are explicitly disabled in the environment or the CRTL does not support
268 them, Perl follows the traditional CRTL behavior of downcasing command\-line
269 arguments and returning file specifications in lower case only.
270 .PP
271 \&\fIN. B.\fR It is very easy to get tripped up using a mixture of other
272 programs, external utilities, and Perl scripts that are in varying
273 states of being able to handle case preservation. For example, a file
274 created by an older version of an archive utility or a build utility
275 such as MMK or MMS may generate a filename in all upper case even on an
276 ODS\-5 volume. If this filename is later retrieved by a Perl script or
277 module in a case preserving environment, that upper case name may not
278 match the mixed\-case or lower\-case expectations of the Perl code. Your
279 best bet is to follow an all\-or\-nothing approach to case preservation:
280 either don\*(Aqt use it at all, or make sure your entire toolchain and
281 application environment support and use it.
282 .PP
283 OpenVMS Alpha v7.3\-1 and later and all version of OpenVMS I64 support
284 case sensitivity as a process setting (see \f(CW\*(C`SET\ PROCESS\ /CASE_LOOKUP=SENSITIVE\*(C'\fR). Perl does not currently support case
285 sensitivity on VMS, but it may in the future, so Perl programs should
286 use the \f(CW\*(C`File::Spec\->case_tolerant\*(C'\fR method to determine the state, and
287 not the \f(CW$^O\fR variable.
288 .SS "Symbolic Links"
289 .IX Subsection "Symbolic Links"
290 When built on an ODS\-5 volume with symbolic links enabled, Perl by
291 default supports symbolic links when the requisite support is available
292 in the filesystem and CRTL (generally 64\-bit OpenVMS v8.3 and later).
293 There are a number of limitations and caveats to be aware of when
294 working with symbolic links on VMS. Most notably, the target of a valid
295 symbolic link must be expressed as a Unix\-style path and it must exist
296 on a volume visible from your POSIX root (see the \f(CW\*(C`SHOW\ ROOT\*(C'\fR command
297 in DCL help). For further details on symbolic link capabilities and
298 requirements, see chapter 12 of the CRTL manual that ships with OpenVMS
299 v8.3 or later.
300 .SS "Wildcard expansion"
301 .IX Subsection "Wildcard expansion"
302 File specifications containing wildcards are allowed both on
303 the command line and within Perl globs (e.g. \f(CW\*(C`<*.c>\*(C'\fR). If
304 the wildcard filespec uses VMS syntax, the resultant
305 filespecs will follow VMS syntax; if a Unix\-style filespec is
306 passed in, Unix\-style filespecs will be returned.
307 Similar to the behavior of wildcard globbing for a Unix shell,
308 one can escape command line wildcards with double quotation
309 marks \f(CW\*(C`"\*(C'\fR around a perl program command line argument. However,
310 owing to the stripping of \f(CW\*(C`"\*(C'\fR characters carried out by the C
311 handling of argv you will need to escape a construct such as
312 this one (in a directory containing the files \fIPERL.C\fR, \fIPERL.EXE\fR,
313 \&\fIPERL.H\fR, and \fIPERL.OBJ\fR):
314 .PP
315 .Vb 2
316 \& $ perl \-e "print join(\*(Aq \*(Aq,@ARGV)" perl.*
317 \& perl.c perl.exe perl.h perl.obj
318 .Ve
319 .PP
320 in the following triple quoted manner:
321 .PP
322 .Vb 2
323 \& $ perl \-e "print join(\*(Aq \*(Aq,@ARGV)" """perl.*"""
324 \& perl.*
325 .Ve
326 .PP
327 In both the case of unquoted command line arguments or in calls
328 to \f(CWglob()\fR VMS wildcard expansion is performed. (csh\-style
329 wildcard expansion is available if you use \f(CW\*(C`File::Glob::glob\*(C'\fR.)
330 If the wildcard filespec contains a device or directory
331 specification, then the resultant filespecs will also contain
332 a device and directory; otherwise, device and directory
333 information are removed. VMS\-style resultant filespecs will
334 contain a full device and directory, while Unix\-style
335 resultant filespecs will contain only as much of a directory
336 path as was present in the input filespec. For example, if
337 your default directory is Perl_Root:[000000], the expansion
338 of \f(CW\*(C`[.t]*.*\*(C'\fR will yield filespecs like
339 "perl_root:[t]base.dir", while the expansion of \f(CW\*(C`t/*/*\*(C'\fR will
340 yield filespecs like "t/base.dir". (This is done to match
341 the behavior of glob expansion performed by Unix shells.)
342 .PP
343 Similarly, the resultant filespec will contain the file version
344 only if one was present in the input filespec.
345 .SS Pipes
346 .IX Subsection "Pipes"
347 Input and output pipes to Perl filehandles are supported; the
348 "file name" is passed to lib$\fBspawn()\fR for asynchronous
349 execution. You should be careful to close any pipes you have
350 opened in a Perl script, lest you leave any "orphaned"
351 subprocesses around when Perl exits.
352 .PP
353 You may also use backticks to invoke a DCL subprocess, whose
354 output is used as the return value of the expression. The
355 string between the backticks is handled as if it were the
356 argument to the \f(CW\*(C`system\*(C'\fR operator (see below). In this case,
357 Perl will wait for the subprocess to complete before continuing.
358 .PP
359 The mailbox (MBX) that perl can create to communicate with a pipe
360 defaults to a buffer size of 8192 on 64\-bit systems, 512 on VAX. The
361 default buffer size is adjustable via the logical name PERL_MBX_SIZE
362 provided that the value falls between 128 and the SYSGEN parameter
363 MAXBUF inclusive. For example, to set the mailbox size to 32767 use
364 \&\f(CW\*(C`$ENV{\*(AqPERL_MBX_SIZE\*(Aq} = 32767;\*(C'\fR and then open and use pipe constructs.
365 An alternative would be to issue the command:
366 .PP
367 .Vb 1
368 \& $ Define PERL_MBX_SIZE 32767
369 .Ve
370 .PP
371 before running your wide record pipe program. A larger value may
372 improve performance at the expense of the BYTLM UAF quota.
373 .SH "PERL5LIB and PERLLIB"
374 .IX Header "PERL5LIB and PERLLIB"
375 The PERL5LIB and PERLLIB environment elements work as documented in perl,
376 except that the element separator is, by default, \*(Aq|\*(Aq instead of \*(Aq:\*(Aq.
377 However, when running under a Unix shell as determined by the logical
378 name \f(CW\*(C`GNV$UNIX_SHELL\*(C'\fR, the separator will be \*(Aq:\*(Aq as on Unix systems. The
379 directory specifications may use either VMS or Unix syntax.
380 .SH "The Perl Forked Debugger"
381 .IX Header "The Perl Forked Debugger"
382 The Perl forked debugger places the debugger commands and output in a
383 separate X\-11 terminal window so that commands and output from multiple
384 processes are not mixed together.
385 .PP
386 Perl on VMS supports an emulation of the forked debugger when Perl is
387 run on a VMS system that has X11 support installed.
388 .PP
389 To use the forked debugger, you need to have the default display set to an
390 X\-11 Server and some environment variables set that Unix expects.
391 .PP
392 The forked debugger requires the environment variable \f(CW\*(C`TERM\*(C'\fR to be \f(CW\*(C`xterm\*(C'\fR,
393 and the environment variable \f(CW\*(C`DISPLAY\*(C'\fR to exist. \f(CW\*(C`xterm\*(C'\fR must be in
394 lower case.
395 .PP
396 .Vb 1
397 \& $define TERM "xterm"
398 \&
399 \& $define DISPLAY "hostname:0.0"
400 .Ve
401 .PP
402 Currently the value of \f(CW\*(C`DISPLAY\*(C'\fR is ignored. It is recommended that it be set
403 to be the hostname of the display, the server and screen in Unix notation. In
404 the future the value of DISPLAY may be honored by Perl instead of using the
405 default display.
406 .PP
407 It may be helpful to always use the forked debugger so that script I/O is
408 separated from debugger I/O. You can force the debugger to be forked by
409 assigning a value to the logical name <PERLDB_PIDS> that is not a process
410 identification number.
411 .PP
412 .Vb 1
413 \& $define PERLDB_PIDS XXXX
414 .Ve
415 .SH PERL_VMS_EXCEPTION_DEBUG
416 .IX Header "PERL_VMS_EXCEPTION_DEBUG"
417 The PERL_VMS_EXCEPTION_DEBUG being defined as "ENABLE" will cause the VMS
418 debugger to be invoked if a fatal exception that is not otherwise
419 handled is raised. The purpose of this is to allow debugging of
420 internal Perl problems that would cause such a condition.
421 .PP
422 This allows the programmer to look at the execution stack and variables to
423 find out the cause of the exception. As the debugger is being invoked as
424 the Perl interpreter is about to do a fatal exit, continuing the execution
425 in debug mode is usually not practical.
426 .PP
427 Starting Perl in the VMS debugger may change the program execution
428 profile in a way that such problems are not reproduced.
429 .PP
430 The \f(CW\*(C`kill\*(C'\fR function can be used to test this functionality from within
431 a program.
432 .PP
433 In typical VMS style, only the first letter of the value of this logical
434 name is actually checked in a case insensitive mode, and it is considered
435 enabled if it is the value "T","1" or "E".
436 .PP
437 This logical name must be defined before Perl is started.
438 .SH "Command line"
439 .IX Header "Command line"
440 .SS "I/O redirection and backgrounding"
441 .IX Subsection "I/O redirection and backgrounding"
442 Perl for VMS supports redirection of input and output on the
443 command line, using a subset of Bourne shell syntax:
444 .IP \(bu 4
445 \&\f(CW\*(C`<file\*(C'\fR reads stdin from \f(CW\*(C`file\*(C'\fR,
446 .IP \(bu 4
447 \&\f(CW\*(C`>file\*(C'\fR writes stdout to \f(CW\*(C`file\*(C'\fR,
448 .IP \(bu 4
449 \&\f(CW\*(C`>>file\*(C'\fR appends stdout to \f(CW\*(C`file\*(C'\fR,
450 .IP \(bu 4
451 \&\f(CW\*(C`2>file\*(C'\fR writes stderr to \f(CW\*(C`file\*(C'\fR,
452 .IP \(bu 4
453 \&\f(CW\*(C`2>>file\*(C'\fR appends stderr to \f(CW\*(C`file\*(C'\fR, and
454 .IP \(bu 4
455 \&\f(CW\*(C`2>&1\*(C'\fR redirects stderr to stdout.
456 .PP
457 In addition, output may be piped to a subprocess, using the
458 character \*(Aq|\*(Aq. Anything after this character on the command
459 line is passed to a subprocess for execution; the subprocess
460 takes the output of Perl as its input.
461 .PP
462 Finally, if the command line ends with \*(Aq&\*(Aq, the entire
463 command is run in the background as an asynchronous
464 subprocess.
465 .SS "Command line switches"
466 .IX Subsection "Command line switches"
467 The following command line switches behave differently under
468 VMS than described in perlrun. Note also that in order
469 to pass uppercase switches to Perl, you need to enclose
470 them in double\-quotes on the command line, since the CRTL
471 downcases all unquoted strings.
472 .PP
473 On newer 64 bit versions of OpenVMS, a process setting now
474 controls if the quoting is needed to preserve the case of
475 command line arguments.
476 .IP \-i 4
477 .IX Item "-i"
478 If the \f(CW\*(C`\-i\*(C'\fR switch is present but no extension for a backup
479 copy is given, then inplace editing creates a new version of
480 a file; the existing copy is not deleted. (Note that if
481 an extension is given, an existing file is renamed to the backup
482 file, as is the case under other operating systems, so it does
483 not remain as a previous version under the original filename.)
484 .IP \-S 4
485 .IX Item "-S"
486 If the \f(CW"\-S"\fR or \f(CW\*(C`\-"S"\*(C'\fR switch is present \fIand\fR the script
487 name does not contain a directory, then Perl translates the
488 logical name DCL$PATH as a searchlist, using each translation
489 as a directory in which to look for the script. In addition,
490 if no file type is specified, Perl looks in each directory
491 for a file matching the name specified, with a blank type,
492 a type of \fI.pl\fR, and a type of \fI.com\fR, in that order.
493 .IP \-u 4
494 .IX Item "-u"
495 The \f(CW\*(C`\-u\*(C'\fR switch causes the VMS debugger to be invoked
496 after the Perl program is compiled, but before it has
497 run. It does not create a core dump file.
498 .SH "Perl functions"
499 .IX Header "Perl functions"
500 As of the time this document was last revised, the following
501 Perl functions were implemented in the VMS port of Perl
502 (functions marked with * are discussed in more detail below):
503 .PP
504 .Vb 10
505 \& file tests*, abs, alarm, atan, backticks*, binmode*, bless,
506 \& caller, chdir, chmod, chown, chomp, chop, chr,
507 \& close, closedir, cos, crypt*, defined, delete, die, do, dump*,
508 \& each, endgrent, endpwent, eof, eval, exec*, exists, exit, exp,
509 \& fileno, flock getc, getgrent*, getgrgid*, getgrnam, getlogin,
510 \& getppid, getpwent*, getpwnam*, getpwuid*, glob, gmtime*, goto,
511 \& grep, hex, ioctl, import, index, int, join, keys, kill*,
512 \& last, lc, lcfirst, lchown*, length, link*, local, localtime, log,
513 \& lstat, m//, map, mkdir, my, next, no, oct, open, opendir, ord,
514 \& pack, pipe, pop, pos, print, printf, push, q//, qq//, qw//,
515 \& qx//*, quotemeta, rand, read, readdir, readlink*, redo, ref,
516 \& rename, require, reset, return, reverse, rewinddir, rindex,
517 \& rmdir, s///, scalar, seek, seekdir, select(internal),
518 \& select (system call)*, setgrent, setpwent, shift, sin, sleep,
519 \& socketpair, sort, splice, split, sprintf, sqrt, srand, stat,
520 \& study, substr, symlink*, sysread, system*, syswrite, tell,
521 \& telldir, tie, time, times*, tr///, uc, ucfirst, umask,
522 \& undef, unlink*, unpack, untie, unshift, use, utime*,
523 \& values, vec, wait, waitpid*, wantarray, warn, write, y///
524 .Ve
525 .PP
526 The following functions were not implemented in the VMS port,
527 and calling them produces a fatal error (usually) or
528 undefined behavior (rarely, we hope):
529 .PP
530 .Vb 4
531 \& chroot, dbmclose, dbmopen, fork*, getpgrp, getpriority,
532 \& msgctl, msgget, msgsend, msgrcv, semctl,
533 \& semget, semop, setpgrp, setpriority, shmctl, shmget,
534 \& shmread, shmwrite, syscall
535 .Ve
536 .PP
537 The following functions are available on Perls compiled with Dec C
538 5.2 or greater and running VMS 7.0 or greater:
539 .PP
540 .Vb 1
541 \& truncate
542 .Ve
543 .PP
544 The following functions are available on Perls built on VMS 7.2 or
545 greater:
546 .PP
547 .Vb 1
548 \& fcntl (without locking)
549 .Ve
550 .PP
551 The following functions may or may not be implemented,
552 depending on what type of socket support you\*(Aqve built into
553 your copy of Perl:
554 .PP
555 .Vb 9
556 \& accept, bind, connect, getpeername,
557 \& gethostbyname, getnetbyname, getprotobyname,
558 \& getservbyname, gethostbyaddr, getnetbyaddr,
559 \& getprotobynumber, getservbyport, gethostent,
560 \& getnetent, getprotoent, getservent, sethostent,
561 \& setnetent, setprotoent, setservent, endhostent,
562 \& endnetent, endprotoent, endservent, getsockname,
563 \& getsockopt, listen, recv, select(system call)*,
564 \& send, setsockopt, shutdown, socket
565 .Ve
566 .PP
567 The following function is available on Perls built on 64 bit OpenVMS v8.2
568 with hard links enabled on an ODS\-5 formatted build disk. CRTL support
569 is in principle available as of OpenVMS v7.3\-1, and better configuration
570 support could detect this.
571 .PP
572 .Vb 1
573 \& link
574 .Ve
575 .PP
576 The following functions are available on Perls built on 64 bit OpenVMS
577 v8.2 and later. CRTL support is in principle available as of OpenVMS
578 v7.3\-2, and better configuration support could detect this.
579 .PP
580 .Vb 2
581 \& getgrgid, getgrnam, getpwnam, getpwuid,
582 \& setgrent, ttyname
583 .Ve
584 .PP
585 The following functions are available on Perls built on 64 bit OpenVMS v8.2
586 and later.
587 .PP
588 .Vb 1
589 \& statvfs, socketpair
590 .Ve
591 .IP "File tests" 4
592 .IX Item "File tests"
593 The tests \f(CW\*(C`\-b\*(C'\fR, \f(CW\*(C`\-B\*(C'\fR, \f(CW\*(C`\-c\*(C'\fR, \f(CW\*(C`\-C\*(C'\fR, \f(CW\*(C`\-d\*(C'\fR, \f(CW\*(C`\-e\*(C'\fR, \f(CW\*(C`\-f\*(C'\fR,
594 \&\f(CW\*(C`\-o\*(C'\fR, \f(CW\*(C`\-M\*(C'\fR, \f(CW\*(C`\-s\*(C'\fR, \f(CW\*(C`\-S\*(C'\fR, \f(CW\*(C`\-t\*(C'\fR, \f(CW\*(C`\-T\*(C'\fR, and \f(CW\*(C`\-z\*(C'\fR work as
595 advertised. The return values for \f(CW\*(C`\-r\*(C'\fR, \f(CW\*(C`\-w\*(C'\fR, and \f(CW\*(C`\-x\*(C'\fR
596 tell you whether you can actually access the file; this may
597 not reflect the UIC\-based file protections. Since real and
598 effective UIC don\*(Aqt differ under VMS, \f(CW\*(C`\-O\*(C'\fR, \f(CW\*(C`\-R\*(C'\fR, \f(CW\*(C`\-W\*(C'\fR,
599 and \f(CW\*(C`\-X\*(C'\fR are equivalent to \f(CW\*(C`\-o\*(C'\fR, \f(CW\*(C`\-r\*(C'\fR, \f(CW\*(C`\-w\*(C'\fR, and \f(CW\*(C`\-x\*(C'\fR.
600 Similarly, several other tests, including \f(CW\*(C`\-A\*(C'\fR, \f(CW\*(C`\-g\*(C'\fR, \f(CW\*(C`\-k\*(C'\fR,
601 \&\f(CW\*(C`\-l\*(C'\fR, \f(CW\*(C`\-p\*(C'\fR, and \f(CW\*(C`\-u\*(C'\fR, aren\*(Aqt particularly meaningful under
602 VMS, and the values returned by these tests reflect whatever
603 your CRTL \f(CWstat()\fR routine does to the equivalent bits in the
604 st_mode field. Finally, \f(CW\*(C`\-d\*(C'\fR returns true if passed a device
605 specification without an explicit directory (e.g. \f(CW\*(C`DUA1:\*(C'\fR), as
606 well as if passed a directory.
607 .Sp
608 There are DECC feature logical names AND ODS\-5 volume attributes that
609 also control what values are returned for the date fields.
610 .Sp
611 Note: Some sites have reported problems when using the file\-access
612 tests (\f(CW\*(C`\-r\*(C'\fR, \f(CW\*(C`\-w\*(C'\fR, and \f(CW\*(C`\-x\*(C'\fR) on files accessed via DEC\*(Aqs DFS.
613 Specifically, since DFS does not currently provide access to the
614 extended file header of files on remote volumes, attempts to
615 examine the ACL fail, and the file tests will return false,
616 with \f(CW$!\fR indicating that the file does not exist. You can
617 use \f(CW\*(C`stat\*(C'\fR on these files, since that checks UIC\-based protection
618 only, and then manually check the appropriate bits, as defined by
619 your C compiler\*(Aqs \fIstat.h\fR, in the mode value it returns, if you
620 need an approximation of the file\*(Aqs protections.
621 .IP backticks 4
622 .IX Item "backticks"
623 Backticks create a subprocess, and pass the enclosed string
624 to it for execution as a DCL command. Since the subprocess is
625 created directly via \f(CW\*(C`lib$spawn()\*(C'\fR, any valid DCL command string
626 may be specified.
627 .IP "binmode FILEHANDLE" 4
628 .IX Item "binmode FILEHANDLE"
629 The \f(CW\*(C`binmode\*(C'\fR operator will attempt to ensure that no translation
630 of carriage control occurs on input from or output to this filehandle.
631 Since this involves reopening the file and then restoring its
632 file position indicator, if this function returns FALSE, the
633 underlying filehandle may no longer point to an open file, or may
634 point to a different position in the file than before \f(CW\*(C`binmode\*(C'\fR
635 was called.
636 .Sp
637 Note that \f(CW\*(C`binmode\*(C'\fR is generally not necessary when using normal
638 filehandles; it is provided so that you can control I/O to existing
639 record\-structured files when necessary. You can also use the
640 \&\f(CW\*(C`vmsfopen\*(C'\fR function in the VMS::Stdio extension to gain finer
641 control of I/O to files and devices with different record structures.
642 .IP "crypt PLAINTEXT, USER" 4
643 .IX Item "crypt PLAINTEXT, USER"
644 The \f(CW\*(C`crypt\*(C'\fR operator uses the \f(CW\*(C`sys$hash_password\*(C'\fR system
645 service to generate the hashed representation of PLAINTEXT.
646 If USER is a valid username, the algorithm and salt values
647 are taken from that user\*(Aqs UAF record. If it is not, then
648 the preferred algorithm and a salt of 0 are used. The
649 quadword encrypted value is returned as an 8\-character string.
650 .Sp
651 The value returned by \f(CW\*(C`crypt\*(C'\fR may be compared against
652 the encrypted password from the UAF returned by the \f(CW\*(C`getpw*\*(C'\fR
653 functions, in order to authenticate users. If you\*(Aqre
654 going to do this, remember that the encrypted password in
655 the UAF was generated using uppercase username and
656 password strings; you\*(Aqll have to upcase the arguments to
657 \&\f(CW\*(C`crypt\*(C'\fR to ensure that you\*(Aqll get the proper value:
658 .Sp
659 .Vb 9
660 \& sub validate_passwd {
661 \& my($user,$passwd) = @_;
662 \& my($pwdhash);
663 \& if ( !($pwdhash = (getpwnam($user))[1]) ||
664 \& $pwdhash ne crypt("\eU$passwd","\eU$name") ) {
665 \& intruder_alert($name);
666 \& }
667 \& return 1;
668 \& }
669 .Ve
670 .IP die 4
671 .IX Item "die"
672 \&\f(CW\*(C`die\*(C'\fR will force the native VMS exit status to be an SS$_ABORT code
673 if neither of the $! or $? status values are ones that would cause
674 the native status to be interpreted as being what VMS classifies as
675 SEVERE_ERROR severity for DCL error handling.
676 .Sp
677 When \f(CW\*(C`PERL_VMS_POSIX_EXIT\*(C'\fR is active (see "$?" below), the native VMS exit
678 status value will have either one of the \f(CW$!\fR or \f(CW$?\fR or \f(CW$^E\fR or
679 the Unix value 255 encoded into it in a way that the effective original
680 value can be decoded by other programs written in C, including Perl
681 and the GNV package. As per the normal non\-VMS behavior of \f(CW\*(C`die\*(C'\fR if
682 either \f(CW$!\fR or \f(CW$?\fR are non\-zero, one of those values will be
683 encoded into a native VMS status value. If both of the Unix status
684 values are 0, and the \f(CW$^E\fR value is set one of ERROR or SEVERE_ERROR
685 severity, then the \f(CW$^E\fR value will be used as the exit code as is.
686 If none of the above apply, the Unix value of 255 will be encoded into
687 a native VMS exit status value.
688 .Sp
689 Please note a significant difference in the behavior of \f(CW\*(C`die\*(C'\fR in
690 the \f(CW\*(C`PERL_VMS_POSIX_EXIT\*(C'\fR mode is that it does not force a VMS
691 SEVERE_ERROR status on exit. The Unix exit values of 2 through
692 255 will be encoded in VMS status values with severity levels of
693 SUCCESS. The Unix exit value of 1 will be encoded in a VMS status
694 value with a severity level of ERROR. This is to be compatible with
695 how the VMS C library encodes these values.
696 .Sp
697 The minimum severity level set by \f(CW\*(C`die\*(C'\fR in \f(CW\*(C`PERL_VMS_POSIX_EXIT\*(C'\fR mode
698 may be changed to be ERROR or higher in the future depending on the
699 results of testing and further review.
700 .Sp
701 See "$?" for a description of the encoding of the Unix value to
702 produce a native VMS status containing it.
703 .IP dump 4
704 .IX Item "dump"
705 Rather than causing Perl to abort and dump core, the \f(CW\*(C`dump\*(C'\fR
706 operator invokes the VMS debugger. If you continue to
707 execute the Perl program under the debugger, control will
708 be transferred to the label specified as the argument to
709 \&\f(CW\*(C`dump\*(C'\fR, or, if no label was specified, back to the
710 beginning of the program. All other state of the program
711 (\fIe.g.\fR values of variables, open file handles) are not
712 affected by calling \f(CW\*(C`dump\*(C'\fR.
713 .IP "exec LIST" 4
714 .IX Item "exec LIST"
715 A call to \f(CW\*(C`exec\*(C'\fR will cause Perl to exit, and to invoke the command
716 given as an argument to \f(CW\*(C`exec\*(C'\fR via \f(CW\*(C`lib$do_command\*(C'\fR. If the
717 argument begins with \*(Aq@\*(Aq or \*(Aq$\*(Aq (other than as part of a filespec),
718 then it is executed as a DCL command. Otherwise, the first token on
719 the command line is treated as the filespec of an image to run, and
720 an attempt is made to invoke it (using \fI.Exe\fR and the process
721 defaults to expand the filespec) and pass the rest of \f(CW\*(C`exec\*(C'\fR\*(Aqs
722 argument to it as parameters. If the token has no file type, and
723 matches a file with null type, then an attempt is made to determine
724 whether the file is an executable image which should be invoked
725 using \f(CW\*(C`MCR\*(C'\fR or a text file which should be passed to DCL as a
726 command procedure.
727 .IP fork 4
728 .IX Item "fork"
729 While in principle the \f(CW\*(C`fork\*(C'\fR operator could be implemented via
730 (and with the same rather severe limitations as) the CRTL \f(CWvfork()\fR
731 routine, and while some internal support to do just that is in
732 place, the implementation has never been completed, making \f(CW\*(C`fork\*(C'\fR
733 currently unavailable. A true kernel \f(CWfork()\fR is expected in a
734 future version of VMS, and the pseudo\-fork based on interpreter
735 threads may be available in a future version of Perl on VMS (see
736 perlfork). In the meantime, use \f(CW\*(C`system\*(C'\fR, backticks, or piped
737 filehandles to create subprocesses.
738 .IP getpwent 4
739 .IX Item "getpwent"
740 .PD 0
741 .IP getpwnam 4
742 .IX Item "getpwnam"
743 .IP getpwuid 4
744 .IX Item "getpwuid"
745 .PD
746 These operators obtain the information described in perlfunc,
747 if you have the privileges necessary to retrieve the named user\*(Aqs
748 UAF information via \f(CW\*(C`sys$getuai\*(C'\fR. If not, then only the \f(CW$name\fR,
749 \&\f(CW$uid\fR, and \f(CW$gid\fR items are returned. The \f(CW$dir\fR item contains
750 the login directory in VMS syntax, while the \f(CW$comment\fR item
751 contains the login directory in Unix syntax. The \f(CW$gcos\fR item
752 contains the owner field from the UAF record. The \f(CW$quota\fR
753 item is not used.
754 .IP gmtime 4
755 .IX Item "gmtime"
756 The \f(CW\*(C`gmtime\*(C'\fR operator will function properly if you have a
757 working CRTL \f(CWgmtime()\fR routine, or if the logical name
758 SYS$TIMEZONE_DIFFERENTIAL is defined as the number of seconds
759 which must be added to UTC to yield local time. (This logical
760 name is defined automatically if you are running a version of
761 VMS with built\-in UTC support.) If neither of these cases is
762 true, a warning message is printed, and \f(CW\*(C`undef\*(C'\fR is returned.
763 .IP kill 4
764 .IX Item "kill"
765 In most cases, \f(CW\*(C`kill\*(C'\fR is implemented via the undocumented system
766 service \f(CW$SIGPRC\fR, which has the same calling sequence as \f(CW$FORCEX\fR, but
767 throws an exception in the target process rather than forcing it to call
768 \&\f(CW$EXIT\fR. Generally speaking, \f(CW\*(C`kill\*(C'\fR follows the behavior of the
769 CRTL\*(Aqs \f(CWkill()\fR function, but unlike that function can be called from
770 within a signal handler. Also, unlike the \f(CW\*(C`kill\*(C'\fR in some versions of
771 the CRTL, Perl\*(Aqs \f(CW\*(C`kill\*(C'\fR checks the validity of the signal passed in and
772 returns an error rather than attempting to send an unrecognized signal.
773 .Sp
774 Also, negative signal values don\*(Aqt do anything special under
775 VMS; they\*(Aqre just converted to the corresponding positive value.
776 .IP qx// 4
777 .IX Item "qx//"
778 See the entry on \f(CW\*(C`backticks\*(C'\fR above.
779 .IP "select (system call)" 4
780 .IX Item "select (system call)"
781 If Perl was not built with socket support, the system call
782 version of \f(CW\*(C`select\*(C'\fR is not available at all. If socket
783 support is present, then the system call version of
784 \&\f(CW\*(C`select\*(C'\fR functions only for file descriptors attached
785 to sockets. It will not provide information about regular
786 files or pipes, since the CRTL \f(CWselect()\fR routine does not
787 provide this functionality.
788 .IP "stat EXPR" 4
789 .IX Item "stat EXPR"
790 Since VMS keeps track of files according to a different scheme
791 than Unix, it\*(Aqs not really possible to represent the file\*(Aqs ID
792 in the \f(CW\*(C`st_dev\*(C'\fR and \f(CW\*(C`st_ino\*(C'\fR fields of a \f(CW\*(C`struct stat\*(C'\fR. Perl
793 tries its best, though, and the values it uses are pretty unlikely
794 to be the same for two different files. We can\*(Aqt guarantee this,
795 though, so caveat scriptor.
796 .IP "system LIST" 4
797 .IX Item "system LIST"
798 The \f(CW\*(C`system\*(C'\fR operator creates a subprocess, and passes its
799 arguments to the subprocess for execution as a DCL command.
800 Since the subprocess is created directly via \f(CW\*(C`lib$spawn()\*(C'\fR, any
801 valid DCL command string may be specified. If the string begins with
802 \&\*(Aq@\*(Aq, it is treated as a DCL command unconditionally. Otherwise, if
803 the first token contains a character used as a delimiter in file
804 specification (e.g. \f(CW\*(C`:\*(C'\fR or \f(CW\*(C`]\*(C'\fR), an attempt is made to expand it
805 using a default type of \fI.Exe\fR and the process defaults, and if
806 successful, the resulting file is invoked via \f(CW\*(C`MCR\*(C'\fR. This allows you
807 to invoke an image directly simply by passing the file specification
808 to \f(CW\*(C`system\*(C'\fR, a common Unixish idiom. If the token has no file type,
809 and matches a file with null type, then an attempt is made to
810 determine whether the file is an executable image which should be
811 invoked using \f(CW\*(C`MCR\*(C'\fR or a text file which should be passed to DCL
812 as a command procedure.
813 .Sp
814 If LIST consists of the empty string, \f(CW\*(C`system\*(C'\fR spawns an
815 interactive DCL subprocess, in the same fashion as typing
816 \&\fBSPAWN\fR at the DCL prompt.
817 .Sp
818 Perl waits for the subprocess to complete before continuing
819 execution in the current process. As described in perlfunc,
820 the return value of \f(CW\*(C`system\*(C'\fR is a fake "status" which follows
821 POSIX semantics unless the pragma \f(CW\*(C`use vmsish \*(Aqstatus\*(Aq\*(C'\fR is in
822 effect; see the description of \f(CW$?\fR in this document for more
823 detail.
824 .IP time 4
825 .IX Item "time"
826 The value returned by \f(CW\*(C`time\*(C'\fR is the offset in seconds from
827 01\-JAN\-1970 00:00:00 (just like the CRTL\*(Aqs \fBtimes()\fR routine), in order
828 to make life easier for code coming in from the POSIX/Unix world.
829 .IP times 4
830 .IX Item "times"
831 The array returned by the \f(CW\*(C`times\*(C'\fR operator is divided up
832 according to the same rules the CRTL \f(CWtimes()\fR routine.
833 Therefore, the "system time" elements will always be 0, since
834 there is no difference between "user time" and "system" time
835 under VMS, and the time accumulated by a subprocess may or may
836 not appear separately in the "child time" field, depending on
837 whether \f(CWtimes()\fR keeps track of subprocesses separately. Note
838 especially that the VAXCRTL (at least) keeps track only of
839 subprocesses spawned using \f(CWfork()\fR and \f(CWexec()\fR; it will not
840 accumulate the times of subprocesses spawned via pipes, \f(CWsystem()\fR,
841 or backticks.
842 .IP "unlink LIST" 4
843 .IX Item "unlink LIST"
844 \&\f(CW\*(C`unlink\*(C'\fR will delete the highest version of a file only; in
845 order to delete all versions, you need to say
846 .Sp
847 .Vb 1
848 \& 1 while unlink LIST;
849 .Ve
850 .Sp
851 You may need to make this change to scripts written for a
852 Unix system which expect that after a call to \f(CW\*(C`unlink\*(C'\fR,
853 no files with the names passed to \f(CW\*(C`unlink\*(C'\fR will exist.
854 (Note: This can be changed at compile time; if you
855 \&\f(CW\*(C`use Config\*(C'\fR and \f(CW$Config{\*(Aqd_unlink_all_versions\*(Aq}\fR is
856 \&\f(CW\*(C`define\*(C'\fR, then \f(CW\*(C`unlink\*(C'\fR will delete all versions of a
857 file on the first call.)
858 .Sp
859 \&\f(CW\*(C`unlink\*(C'\fR will delete a file if at all possible, even if it
860 requires changing file protection (though it won\*(Aqt try to
861 change the protection of the parent directory). You can tell
862 whether you\*(Aqve got explicit delete access to a file by using the
863 \&\f(CW\*(C`VMS::Filespec::candelete\*(C'\fR operator. For instance, in order
864 to delete only files to which you have delete access, you could
865 say something like
866 .Sp
867 .Vb 8
868 \& sub safe_unlink {
869 \& my($file,$num);
870 \& foreach $file (@_) {
871 \& next unless VMS::Filespec::candelete($file);
872 \& $num += unlink $file;
873 \& }
874 \& $num;
875 \& }
876 .Ve
877 .Sp
878 (or you could just use \f(CW\*(C`VMS::Stdio::remove\*(C'\fR, if you\*(Aqve installed
879 the VMS::Stdio extension distributed with Perl). If \f(CW\*(C`unlink\*(C'\fR has to
880 change the file protection to delete the file, and you interrupt it
881 in midstream, the file may be left intact, but with a changed ACL
882 allowing you delete access.
883 .Sp
884 This behavior of \f(CW\*(C`unlink\*(C'\fR is to be compatible with POSIX behavior
885 and not traditional VMS behavior.
886 .IP "utime LIST" 4
887 .IX Item "utime LIST"
888 This operator changes only the modification time of the file (VMS
889 revision date) on ODS\-2 volumes and ODS\-5 volumes without access
890 dates enabled. On ODS\-5 volumes with access dates enabled, the
891 true access time is modified.
892 .IP "waitpid PID,FLAGS" 4
893 .IX Item "waitpid PID,FLAGS"
894 If PID is a subprocess started by a piped \f(CWopen()\fR (see open),
895 \&\f(CW\*(C`waitpid\*(C'\fR will wait for that subprocess, and return its final status
896 value in \f(CW$?\fR. If PID is a subprocess created in some other way (e.g.
897 SPAWNed before Perl was invoked), \f(CW\*(C`waitpid\*(C'\fR will simply check once per
898 second whether the process has completed, and return when it has. (If
899 PID specifies a process that isn\*(Aqt a subprocess of the current process,
900 and you invoked Perl with the \f(CW\*(C`\-w\*(C'\fR switch, a warning will be issued.)
901 .Sp
902 Returns PID on success, \-1 on error. The FLAGS argument is ignored
903 in all cases.
904 .SH "Perl variables"
905 .IX Header "Perl variables"
906 The following VMS\-specific information applies to the indicated
907 "special" Perl variables, in addition to the general information
908 in perlvar. Where there is a conflict, this information
909 takes precedence.
910 .ie n .IP %ENV 4
911 .el .IP \f(CW%ENV\fR 4
912 .IX Item "%ENV"
913 The operation of the \f(CW%ENV\fR array depends on the translation
914 of the logical name \fIPERL_ENV_TABLES\fR. If defined, it should
915 be a search list, each element of which specifies a location
916 for \f(CW%ENV\fR elements. If you tell Perl to read or set the
917 element \f(CW\*(C`$ENV{\*(C'\fR\fIname\fR\f(CW\*(C`}\*(C'\fR, then Perl uses the translations of
918 \&\fIPERL_ENV_TABLES\fR as follows:
919 .RS 4
920 .IP CRTL_ENV 4
921 .IX Item "CRTL_ENV"
922 This string tells Perl to consult the CRTL\*(Aqs internal \f(CW\*(C`environ\*(C'\fR array
923 of key\-value pairs, using \fIname\fR as the key. In most cases, this
924 contains only a few keys, but if Perl was invoked via the C
925 \&\f(CW\*(C`exec[lv]e()\*(C'\fR function, as is the case for some embedded Perl
926 applications or when running under a shell such as GNV bash, the
927 \&\f(CW\*(C`environ\*(C'\fR array may have been populated by the calling program.
928 .IP CLISYM_[LOCAL] 4
929 .IX Item "CLISYM_[LOCAL]"
930 A string beginning with \f(CW\*(C`CLISYM_\*(C'\fRtells Perl to consult the CLI\*(Aqs
931 symbol tables, using \fIname\fR as the name of the symbol. When reading
932 an element of \f(CW%ENV\fR, the local symbol table is scanned first, followed
933 by the global symbol table.. The characters following \f(CW\*(C`CLISYM_\*(C'\fR are
934 significant when an element of \f(CW%ENV\fR is set or deleted: if the
935 complete string is \f(CW\*(C`CLISYM_LOCAL\*(C'\fR, the change is made in the local
936 symbol table; otherwise the global symbol table is changed.
937 .IP "Any other string" 4
938 .IX Item "Any other string"
939 If an element of \fIPERL_ENV_TABLES\fR translates to any other string,
940 that string is used as the name of a logical name table, which is
941 consulted using \fIname\fR as the logical name. The normal search
942 order of access modes is used.
943 .RE
944 .RS 4
945 .Sp
946 \&\fIPERL_ENV_TABLES\fR is translated once when Perl starts up; any changes
947 you make while Perl is running do not affect the behavior of \f(CW%ENV\fR.
948 If \fIPERL_ENV_TABLES\fR is not defined, then Perl defaults to consulting
949 first the logical name tables specified by \fILNM$FILE_DEV\fR, and then
950 the CRTL \f(CW\*(C`environ\*(C'\fR array. This default order is reversed when the
951 logical name \fIGNV$UNIX_SHELL\fR is defined, such as when running under
952 GNV bash.
953 .Sp
954 For operations on \f(CW%ENV\fR entries based on logical names or DCL symbols, the
955 key string is treated as if it were entirely uppercase, regardless of the
956 case actually specified in the Perl expression. Entries in \f(CW%ENV\fR based on the
957 CRTL\*(Aqs environ array preserve the case of the key string when stored, and
958 lookups are case sensitive.
959 .Sp
960 When an element of \f(CW%ENV\fR is read, the locations to which
961 \&\fIPERL_ENV_TABLES\fR points are checked in order, and the value
962 obtained from the first successful lookup is returned. If the
963 name of the \f(CW%ENV\fR element contains a semi\-colon, it and
964 any characters after it are removed. These are ignored when
965 the CRTL \f(CW\*(C`environ\*(C'\fR array or a CLI symbol table is consulted.
966 However, the name is looked up in a logical name table, the
967 suffix after the semi\-colon is treated as the translation index
968 to be used for the lookup. This lets you look up successive values
969 for search list logical names. For instance, if you say
970 .Sp
971 .Vb 3
972 \& $ Define STORY once,upon,a,time,there,was
973 \& $ perl \-e "for ($i = 0; $i <= 6; $i++) " \-
974 \& _$ \-e "{ print $ENV{\*(Aqstory;\*(Aq.$i},\*(Aq \*(Aq}"
975 .Ve
976 .Sp
977 Perl will print \f(CW\*(C`ONCE UPON A TIME THERE WAS\*(C'\fR, assuming, of course,
978 that \fIPERL_ENV_TABLES\fR is set up so that the logical name \f(CW\*(C`story\*(C'\fR
979 is found, rather than a CLI symbol or CRTL \f(CW\*(C`environ\*(C'\fR element with
980 the same name.
981 .Sp
982 When an element of \f(CW%ENV\fR is set to a defined string, the
983 corresponding definition is made in the location to which the
984 first translation of \fIPERL_ENV_TABLES\fR points. If this causes a
985 logical name to be created, it is defined in supervisor mode.
986 (The same is done if an existing logical name was defined in
987 executive or kernel mode; an existing user or supervisor mode
988 logical name is reset to the new value.) If the value is an empty
989 string, the logical name\*(Aqs translation is defined as a single \f(CW\*(C`NUL\*(C'\fR
990 (ASCII \f(CW\*(C`\e0\*(C'\fR) character, since a logical name cannot translate to a
991 zero\-length string. (This restriction does not apply to CLI symbols
992 or CRTL \f(CW\*(C`environ\*(C'\fR values; they are set to the empty string.)
993 .Sp
994 When an element of \f(CW%ENV\fR is set to \f(CW\*(C`undef\*(C'\fR, the element is looked
995 up as if it were being read, and if it is found, it is deleted. (An
996 item "deleted" from the CRTL \f(CW\*(C`environ\*(C'\fR array is set to the empty
997 string.) Using \f(CW\*(C`delete\*(C'\fR to remove an element from \f(CW%ENV\fR has a
998 similar effect, but after the element is deleted, another attempt is
999 made to look up the element, so an inner\-mode logical name or a name
1000 in another location will replace the logical name just deleted. In
1001 either case, only the first value found searching PERL_ENV_TABLES is
1002 altered. It is not possible at present to define a search list
1003 logical name via \f(CW%ENV\fR.
1004 .Sp
1005 The element \f(CW$ENV{DEFAULT}\fR is special: when read, it returns
1006 Perl\*(Aqs current default device and directory, and when set, it
1007 resets them, regardless of the definition of \fIPERL_ENV_TABLES\fR.
1008 It cannot be cleared or deleted; attempts to do so are silently
1009 ignored.
1010 .Sp
1011 Note that if you want to pass on any elements of the
1012 C\-local environ array to a subprocess which isn\*(Aqt
1013 started by fork/exec, or isn\*(Aqt running a C program, you
1014 can "promote" them to logical names in the current
1015 process, which will then be inherited by all subprocesses,
1016 by saying
1017 .Sp
1018 .Vb 4
1019 \& foreach my $key (qw[C\-local keys you want promoted]) {
1020 \& my $temp = $ENV{$key}; # read from C\-local array
1021 \& $ENV{$key} = $temp; # and define as logical name
1022 \& }
1023 .Ve
1024 .Sp
1025 (You can\*(Aqt just say \f(CW\*(C`$ENV{$key} = $ENV{$key}\*(C'\fR, since the
1026 Perl optimizer is smart enough to elide the expression.)
1027 .Sp
1028 Don\*(Aqt try to clear \f(CW%ENV\fR by saying \f(CW\*(C`%ENV = ();\*(C'\fR, it will throw
1029 a fatal error. This is equivalent to doing the following from DCL:
1030 .Sp
1031 .Vb 1
1032 \& DELETE/LOGICAL *
1033 .Ve
1034 .Sp
1035 You can imagine how bad things would be if, for example, the SYS$MANAGER
1036 or SYS$SYSTEM logical names were deleted.
1037 .Sp
1038 At present, the first time you iterate over \f(CW%ENV\fR using
1039 \&\f(CW\*(C`keys\*(C'\fR, or \f(CW\*(C`values\*(C'\fR, you will incur a time penalty as all
1040 logical names are read, in order to fully populate \f(CW%ENV\fR.
1041 Subsequent iterations will not reread logical names, so they
1042 won\*(Aqt be as slow, but they also won\*(Aqt reflect any changes
1043 to logical name tables caused by other programs.
1044 .Sp
1045 You do need to be careful with the logical names representing
1046 process\-permanent files, such as \f(CW\*(C`SYS$INPUT\*(C'\fR and \f(CW\*(C`SYS$OUTPUT\*(C'\fR.
1047 The translations for these logical names are prepended with a
1048 two\-byte binary value (0x1B 0x00) that needs to be stripped off
1049 if you want to use it. (In previous versions of Perl it wasn\*(Aqt
1050 possible to get the values of these logical names, as the null
1051 byte acted as an end\-of\-string marker)
1052 .RE
1053 .IP $! 4
1054 The string value of \f(CW$!\fR is that returned by the CRTL\*(Aqs
1055 \&\fBstrerror()\fR function, so it will include the VMS message for
1056 VMS\-specific errors. The numeric value of \f(CW$!\fR is the
1057 value of \f(CW\*(C`errno\*(C'\fR, except if errno is EVMSERR, in which
1058 case \f(CW$!\fR contains the value of vaxc$errno. Setting \f(CW$!\fR
1059 always sets errno to the value specified. If this value is
1060 EVMSERR, it also sets vaxc$errno to 4 (NONAME\-F\-NOMSG), so
1061 that the string value of \f(CW$!\fR won\*(Aqt reflect the VMS error
1062 message from before \f(CW$!\fR was set.
1063 .IP $^E 4
1064 .IX Item "$^E"
1065 This variable provides direct access to VMS status values
1066 in vaxc$errno, which are often more specific than the
1067 generic Unix\-style error messages in \f(CW$!\fR. Its numeric value
1068 is the value of vaxc$errno, and its string value is the
1069 corresponding VMS message string, as retrieved by sys$\fBgetmsg()\fR.
1070 Setting \f(CW$^E\fR sets vaxc$errno to the value specified.
1071 .Sp
1072 While Perl attempts to keep the vaxc$errno value to be current, if
1073 errno is not EVMSERR, it may not be from the current operation.
1074 .IP $? 4
1075 The "status value" returned in \f(CW$?\fR is synthesized from the
1076 actual exit status of the subprocess in a way that approximates
1077 POSIX \fBwait\fR\|(5) semantics, in order to allow Perl programs to
1078 portably test for successful completion of subprocesses. The
1079 low order 8 bits of \f(CW$?\fR are always 0 under VMS, since the
1080 termination status of a process may or may not have been
1081 generated by an exception.
1082 .Sp
1083 The next 8 bits contain the termination status of the program.
1084 .Sp
1085 If the child process follows the convention of C programs
1086 compiled with the _POSIX_EXIT macro set, the status value will
1087 contain the actual value of 0 to 255 returned by that program
1088 on a normal exit.
1089 .Sp
1090 With the _POSIX_EXIT macro set, the Unix exit value of zero is
1091 represented as a VMS native status of 1, and the Unix values
1092 from 2 to 255 are encoded by the equation:
1093 .Sp
1094 .Vb 1
1095 \& VMS_status = 0x35a000 + (unix_value * 8) + 1.
1096 .Ve
1097 .Sp
1098 And in the special case of Unix value 1 the encoding is:
1099 .Sp
1100 .Vb 1
1101 \& VMS_status = 0x35a000 + 8 + 2 + 0x10000000.
1102 .Ve
1103 .Sp
1104 For other termination statuses, the severity portion of the
1105 subprocess\*(Aqs exit status is used: if the severity was success or
1106 informational, these bits are all 0; if the severity was
1107 warning, they contain a value of 1; if the severity was
1108 error or fatal error, they contain the actual severity bits,
1109 which turns out to be a value of 2 for error and 4 for severe_error.
1110 Fatal is another term for the severe_error status.
1111 .Sp
1112 As a result, \f(CW$?\fR will always be zero if the subprocess\*(Aqs exit
1113 status indicated successful completion, and non\-zero if a
1114 warning or error occurred or a program compliant with encoding
1115 _POSIX_EXIT values was run and set a status.
1116 .Sp
1117 How can you tell the difference between a non\-zero status that is
1118 the result of a VMS native error status or an encoded Unix status?
1119 You can not unless you look at the ${^CHILD_ERROR_NATIVE} value.
1120 The ${^CHILD_ERROR_NATIVE} value returns the actual VMS status value
1121 and check the severity bits. If the severity bits are equal to 1,
1122 then if the numeric value for \f(CW$?\fR is between 2 and 255 or 0, then
1123 \&\f(CW$?\fR accurately reflects a value passed back from a Unix application.
1124 If \f(CW$?\fR is 1, and the severity bits indicate a VMS error (2), then
1125 \&\f(CW$?\fR is from a Unix application exit value.
1126 .Sp
1127 In practice, Perl scripts that call programs that return _POSIX_EXIT
1128 type status values will be expecting those values, and programs that
1129 call traditional VMS programs will either be expecting the previous
1130 behavior or just checking for a non\-zero status.
1131 .Sp
1132 And success is always the value 0 in all behaviors.
1133 .Sp
1134 When the actual VMS termination status of the child is an error,
1135 internally the \f(CW$!\fR value will be set to the closest Unix errno
1136 value to that error so that Perl scripts that test for error
1137 messages will see the expected Unix style error message instead
1138 of a VMS message.
1139 .Sp
1140 Conversely, when setting \f(CW$?\fR in an END block, an attempt is made
1141 to convert the POSIX value into a native status intelligible to
1142 the operating system upon exiting Perl. What this boils down to
1143 is that setting \f(CW$?\fR to zero results in the generic success value
1144 SS$_NORMAL, and setting \f(CW$?\fR to a non\-zero value results in the
1145 generic failure status SS$_ABORT. See also "exit" in perlport.
1146 .Sp
1147 With the \f(CW\*(C`PERL_VMS_POSIX_EXIT\*(C'\fR logical name defined as "ENABLE",
1148 setting \f(CW$?\fR will cause the new value to be encoded into \f(CW$^E\fR
1149 so that either the original parent or child exit status values
1150 0 to 255 can be automatically recovered by C programs expecting
1151 _POSIX_EXIT behavior. If both a parent and a child exit value are
1152 non\-zero, then it will be assumed that this is actually a VMS native
1153 status value to be passed through. The special value of 0xFFFF is
1154 almost a NOOP as it will cause the current native VMS status in the
1155 C library to become the current native Perl VMS status, and is handled
1156 this way as it is known to not be a valid native VMS status value.
1157 It is recommended that only values in the range of normal Unix parent or
1158 child status numbers, 0 to 255 are used.
1159 .Sp
1160 The pragma \f(CW\*(C`use vmsish \*(Aqstatus\*(Aq\*(C'\fR makes \f(CW$?\fR reflect the actual
1161 VMS exit status instead of the default emulation of POSIX status
1162 described above. This pragma also disables the conversion of
1163 non\-zero values to SS$_ABORT when setting \f(CW$?\fR in an END
1164 block (but zero will still be converted to SS$_NORMAL).
1165 .Sp
1166 Do not use the pragma \f(CW\*(C`use vmsish \*(Aqstatus\*(Aq\*(C'\fR with \f(CW\*(C`PERL_VMS_POSIX_EXIT\*(C'\fR
1167 enabled, as they are at times requesting conflicting actions and the
1168 consequence of ignoring this advice will be undefined to allow future
1169 improvements in the POSIX exit handling.
1170 .Sp
1171 In general, with \f(CW\*(C`PERL_VMS_POSIX_EXIT\*(C'\fR enabled, more detailed information
1172 will be available in the exit status for DCL scripts or other native VMS tools,
1173 and will give the expected information for Posix programs. It has not been
1174 made the default in order to preserve backward compatibility.
1175 .Sp
1176 N.B. Setting \f(CW\*(C`DECC$FILENAME_UNIX_REPORT\*(C'\fR implicitly enables
1177 \&\f(CW\*(C`PERL_VMS_POSIX_EXIT\*(C'\fR.
1178 .IP $| 4
1179 Setting \f(CW$|\fR for an I/O stream causes data to be flushed
1180 all the way to disk on each write (\fIi.e.\fR not just to
1181 the underlying RMS buffers for a file). In other words,
1182 it\*(Aqs equivalent to calling \fBfflush()\fR and \fBfsync()\fR from C.
1183 .SH "Standard modules with VMS\-specific differences"
1184 .IX Header "Standard modules with VMS-specific differences"
1185 .SS SDBM_File
1186 .IX Subsection "SDBM_File"
1187 SDBM_File works properly on VMS. It has, however, one minor
1188 difference. The database directory file created has a \fI.sdbm_dir\fR
1189 extension rather than a \fI.dir\fR extension. \fI.dir\fR files are VMS filesystem
1190 directory files, and using them for other purposes could cause unacceptable
1191 problems.
1192 .SH "Revision date"
1193 .IX Header "Revision date"
1194 Please see the git repository for revision history.
1195 .SH AUTHOR
1196 .IX Header "AUTHOR"
1197 Charles Bailey [email protected]
1198 Craig Berry [email protected]
1199 Dan Sugalski [email protected]
1200 John Malmberg [email protected]