1PERLVMS(1)             Perl Programmers Reference Guide             PERLVMS(1)
2
3
4

NAME

6       perlvms - VMS-specific documentation for Perl
7

DESCRIPTION

9       Gathered below are notes describing details of Perl 5's behavior on
10       VMS.  They are a supplement to the regular Perl 5 documentation, so we
11       have focussed on the ways in which Perl 5 functions differently under
12       VMS than it does under Unix, and on the interactions between Perl and
13       the rest of the operating system.  We haven't tried to duplicate
14       complete descriptions of Perl features from the main Perl
15       documentation, which can be found in the [.pod] subdirectory of the
16       Perl distribution.
17
18       We hope these notes will save you from confusion and lost sleep when
19       writing Perl scripts on VMS.  If you find we've missed something you
20       think should appear here, please don't hesitate to drop a line to
21       vmsperl@perl.org.
22

Installation

24       Directions for building and installing Perl 5 can be found in the file
25       README.vms in the main source directory of the Perl distribution..
26

Organization of Perl Images

28   Core Images
29       During the installation process, three Perl images are produced.
30       Miniperl.Exe is an executable image which contains all of the basic
31       functionality of Perl, but cannot take advantage of Perl extensions.
32       It is used to generate several files needed to build the complete Perl
33       and various extensions.  Once you've finished installing Perl, you can
34       delete this image.
35
36       Most of the complete Perl resides in the shareable image PerlShr.Exe,
37       which provides a core to which the Perl executable image and all Perl
38       extensions are linked.  You should place this image in Sys$Share, or
39       define the logical name PerlShr to translate to the full file
40       specification of this image.  It should be world readable.  (Remember
41       that if a user has execute only access to PerlShr, VMS will treat it as
42       if it were a privileged shareable image, and will therefore require all
43       downstream shareable images to be INSTALLed, etc.)
44
45       Finally, Perl.Exe is an executable image containing the main entry
46       point for Perl, as well as some initialization code.  It should be
47       placed in a public directory, and made world executable.  In order to
48       run Perl with command line arguments, you should define a foreign
49       command to invoke this image.
50
51   Perl Extensions
52       Perl extensions are packages which provide both XS and Perl code to add
53       new functionality to perl.  (XS is a meta-language which simplifies
54       writing C code which interacts with Perl, see perlxs for more details.)
55       The Perl code for an extension is treated like any other library module
56       - it's made available in your script through the appropriate "use" or
57       "require" statement, and usually defines a Perl package containing the
58       extension.
59
60       The portion of the extension provided by the XS code may be connected
61       to the rest of Perl in either of two ways.  In the static
62       configuration, the object code for the extension is linked directly
63       into PerlShr.Exe, and is initialized whenever Perl is invoked.  In the
64       dynamic configuration, the extension's machine code is placed into a
65       separate shareable image, which is mapped by Perl's DynaLoader when the
66       extension is "use"d or "require"d in your script.  This allows you to
67       maintain the extension as a separate entity, at the cost of keeping
68       track of the additional shareable image.  Most extensions can be set up
69       as either static or dynamic.
70
71       The source code for an extension usually resides in its own directory.
72       At least three files are generally provided: Extshortname.xs (where
73       Extshortname is the portion of the extension's name following the last
74       "::"), containing the XS code, Extshortname.pm, the Perl library module
75       for the extension, and Makefile.PL, a Perl script which uses the
76       "MakeMaker" library modules supplied with Perl to generate a
77       Descrip.MMS file for the extension.
78
79   Installing static extensions
80       Since static extensions are incorporated directly into PerlShr.Exe,
81       you'll have to rebuild Perl to incorporate a new extension.  You should
82       edit the main Descrip.MMS or Makefile you use to build Perl, adding the
83       extension's name to the "ext" macro, and the extension's object file to
84       the "extobj" macro.  You'll also need to build the extension's object
85       file, either by adding dependencies to the main Descrip.MMS, or using a
86       separate Descrip.MMS for the extension.  Then, rebuild PerlShr.Exe to
87       incorporate the new code.
88
89       Finally, you'll need to copy the extension's Perl library module to the
90       [.Extname] subdirectory under one of the directories in @INC, where
91       Extname is the name of the extension, with all "::" replaced by "."
92       (e.g.  the library module for extension Foo::Bar would be copied to a
93       [.Foo.Bar] subdirectory).
94
95   Installing dynamic extensions
96       In general, the distributed kit for a Perl extension includes a file
97       named Makefile.PL, which is a Perl program which is used to create a
98       Descrip.MMS file which can be used to build and install the files
99       required by the extension.  The kit should be unpacked into a directory
100       tree not under the main Perl source directory, and the procedure for
101       building the extension is simply
102
103           $ perl Makefile.PL  ! Create Descrip.MMS
104           $ mmk               ! Build necessary files
105           $ mmk test          ! Run test code, if supplied
106           $ mmk install       ! Install into public Perl tree
107
108       N.B. The procedure by which extensions are built and tested creates
109       several levels (at least 4) under the directory in which the
110       extension's source files live.  For this reason if you are running a
111       version of VMS prior to V7.1 you shouldn't nest the source directory
112       too deeply in your directory structure lest you exceed RMS' maximum of
113       8 levels of subdirectory in a filespec.  (You can use rooted logical
114       names to get another 8 levels of nesting, if you can't place the files
115       near the top of the physical directory structure.)
116
117       VMS support for this process in the current release of Perl is
118       sufficient to handle most extensions.  However, it does not yet
119       recognize extra libraries required to build shareable images which are
120       part of an extension, so these must be added to the linker options file
121       for the extension by hand.  For instance, if the PGPLOT extension to
122       Perl requires the PGPLOTSHR.EXE shareable image in order to properly
123       link the Perl extension, then the line "PGPLOTSHR/Share" must be added
124       to the linker options file PGPLOT.Opt produced during the build process
125       for the Perl extension.
126
127       By default, the shareable image for an extension is placed in the
128       [.lib.site_perl.autoArch.Extname] directory of the installed Perl
129       directory tree (where Arch is VMS_VAX or VMS_AXP, and Extname is the
130       name of the extension, with each "::" translated to ".").  (See the
131       MakeMaker documentation for more details on installation options for
132       extensions.)  However, it can be manually placed in any of several
133       locations:
134
135       ·   the [.Lib.Auto.Arch$PVersExtname] subdirectory of one of the
136           directories in @INC (where PVers is the version of Perl you're
137           using, as supplied in $], with '.' converted to '_'), or
138
139       ·   one of the directories in @INC, or
140
141       ·   a directory which the extensions Perl library module passes to the
142           DynaLoader when asking it to map the shareable image, or
143
144       ·   Sys$Share or Sys$Library.
145
146       If the shareable image isn't in any of these places, you'll need to
147       define a logical name Extshortname, where Extshortname is the portion
148       of the extension's name after the last "::", which translates to the
149       full file specification of the shareable image.
150

File specifications

152   Syntax
153       We have tried to make Perl aware of both VMS-style and Unix-style file
154       specifications wherever possible.  You may use either style, or both,
155       on the command line and in scripts, but you may not combine the two
156       styles within a single file specification.  VMS Perl interprets Unix
157       pathnames in much the same way as the CRTL (e.g. the first component of
158       an absolute path is read as the device name for the VMS file
159       specification).  There are a set of functions provided in the
160       "VMS::Filespec" package for explicit interconversion between VMS and
161       Unix syntax; its documentation provides more details.
162
163       We've tried to minimize the dependence of Perl library modules on Unix
164       syntax, but you may find that some of these, as well as some scripts
165       written for Unix systems, will require that you use Unix syntax, since
166       they will assume that '/' is the directory separator, etc.  If you find
167       instances of this in the Perl distribution itself, please let us know,
168       so we can try to work around them.
169
170       Also when working on Perl programs on VMS, if you need a syntax in a
171       specific operating system format, then you need either to check the
172       appropriate DECC$ feature logical, or call a conversion routine to
173       force it to that format.
174
175       The feature logical name DECC$FILENAME_UNIX_REPORT modifies traditional
176       Perl behavior in the conversion of file specifications from Unix to VMS
177       format in order to follow the extended character handling rules now
178       expected by the CRTL.  Specifically, when this feature is in effect,
179       the "./.../" in a Unix path is now translated to "[.^.^.^.]" instead of
180       the traditional VMS "[...]".  To be compatible with what MakeMaker
181       expects, if a VMS path cannot be translated to a Unix path, it is
182       passed through unchanged, so "unixify("[...]")" will return "[...]".
183
184       The handling of extended characters is largely complete in the VMS-
185       specific C infrastructure of Perl, but more work is still needed to
186       fully support extended syntax filenames in several core modules.  In
187       particular, at this writing PathTools has only partial support for
188       directories containing some extended characters.
189
190       There are several ambiguous cases where a conversion routine cannot
191       determine whether an input filename is in Unix format or in VMS format,
192       since now both VMS and Unix file specifications may have characters in
193       them that could be mistaken for syntax delimiters of the other type. So
194       some pathnames simply cannot be used in a mode that allows either type
195       of pathname to be present.  Perl will tend to assume that an ambiguous
196       filename is in Unix format.
197
198       Allowing "." as a version delimiter is simply incompatible with
199       determining whether a pathname is in VMS format or in Unix format with
200       extended file syntax.  There is no way to know whether "perl-5.8.6" is
201       a Unix "perl-5.8.6" or a VMS "perl-5.8;6" when passing it to unixify()
202       or vmsify().
203
204       The DECC$FILENAME_UNIX_REPORT logical name controls how Perl interprets
205       filenames to the extent that Perl uses the CRTL internally for many
206       purposes, and attempts to follow CRTL conventions for reporting
207       filenames.  The DECC$FILENAME_UNIX_ONLY feature differs in that it
208       expects all filenames passed to the C run-time to be already in Unix
209       format.  This feature is not yet supported in Perl since Perl uses
210       traditional OpenVMS file specifications internally and in the test
211       harness, and it is not yet clear whether this mode will be useful or
212       useable.  The feature logical name DECC$POSIX_COMPLIANT_PATHNAMES is
213       new with the RMS Symbolic Link SDK and included with OpenVMS v8.3, but
214       is not yet supported in Perl.
215
216   Filename Case
217       Perl follows VMS defaults and override settings in preserving (or not
218       preserving) filename case.  Case is not preserved on ODS-2 formatted
219       volumes on any architecture.  On ODS-5 volumes, filenames may be case
220       preserved depending on process and feature settings.  Perl now honors
221       DECC$EFS_CASE_PRESERVE and DECC$ARGV_PARSE_STYLE on those systems where
222       the CRTL supports these features.  When these features are not enabled
223       or the CRTL does not support them, Perl follows the traditional CRTL
224       behavior of downcasing command-line arguments and returning file
225       specifications in lower case only.
226
227       N. B.  It is very easy to get tripped up using a mixture of other
228       programs, external utilities, and Perl scripts that are in varying
229       states of being able to handle case preservation.  For example, a file
230       created by an older version of an archive utility or a build utility
231       such as MMK or MMS may generate a filename in all upper case even on an
232       ODS-5 volume.  If this filename is later retrieved by a Perl script or
233       module in a case preserving environment, that upper case name may not
234       match the mixed-case or lower-case expections of the Perl code.  Your
235       best bet is to follow an all-or-nothing approach to case preservation:
236       either don't use it at all, or make sure your entire toolchain and
237       application environment support and use it.
238
239       OpenVMS Alpha v7.3-1 and later and all version of OpenVMS I64 support
240       case sensitivity as a process setting (see "SET PROCESS
241       /CASE_LOOKUP=SENSITIVE"). Perl does not currently suppport case
242       sensitivity on VMS, but it may in the future, so Perl programs should
243       use the "File::Spec->case_tolerant" method to determine the state, and
244       not the $^O variable.
245
246   Symbolic Links
247       When built on an ODS-5 volume with symbolic links enabled, Perl by
248       default supports symbolic links when the requisite support is available
249       in the filesystem and CRTL (generally 64-bit OpenVMS v8.3 and later).
250       There are a number of limitations and caveats to be aware of when
251       working with symbolic links on VMS.  Most notably, the target of a
252       valid symbolic link must be expressed as a Unix-style path and it must
253       exist on a volume visible from your POSIX root (see the "SHOW ROOT"
254       command in DCL help).  For further details on symbolic link
255       capabilities and requirements, see chapter 12 of the CRTL manual that
256       ships with OpenVMS v8.3 or later.
257
258   Wildcard expansion
259       File specifications containing wildcards are allowed both on the
260       command line and within Perl globs (e.g. "<*.c>").  If the wildcard
261       filespec uses VMS syntax, the resultant filespecs will follow VMS
262       syntax; if a Unix-style filespec is passed in, Unix-style filespecs
263       will be returned.  Similar to the behavior of wildcard globbing for a
264       Unix shell, one can escape command line wildcards with double quotation
265       marks """ around a perl program command line argument.  However, owing
266       to the stripping of """ characters carried out by the C handling of
267       argv you will need to escape a construct such as this one (in a
268       directory containing the files PERL.C, PERL.EXE, PERL.H, and PERL.OBJ):
269
270           $ perl -e "print join(' ',@ARGV)" perl.*
271           perl.c perl.exe perl.h perl.obj
272
273       in the following triple quoted manner:
274
275           $ perl -e "print join(' ',@ARGV)" """perl.*"""
276           perl.*
277
278       In both the case of unquoted command line arguments or in calls to
279       "glob()" VMS wildcard expansion is performed. (csh-style wildcard
280       expansion is available if you use "File::Glob::glob".)  If the wildcard
281       filespec contains a device or directory specification, then the
282       resultant filespecs will also contain a device and directory;
283       otherwise, device and directory information are removed.  VMS-style
284       resultant filespecs will contain a full device and directory, while
285       Unix-style resultant filespecs will contain only as much of a directory
286       path as was present in the input filespec.  For example, if your
287       default directory is Perl_Root:[000000], the expansion of "[.t]*.*"
288       will yield filespecs  like "perl_root:[t]base.dir", while the expansion
289       of "t/*/*" will yield filespecs like "t/base.dir".  (This is done to
290       match the behavior of glob expansion performed by Unix shells.)
291
292       Similarly, the resultant filespec will contain the file version only if
293       one was present in the input filespec.
294
295   Pipes
296       Input and output pipes to Perl filehandles are supported; the "file
297       name" is passed to lib$spawn() for asynchronous execution.  You should
298       be careful to close any pipes you have opened in a Perl script, lest
299       you leave any "orphaned" subprocesses around when Perl exits.
300
301       You may also use backticks to invoke a DCL subprocess, whose output is
302       used as the return value of the expression.  The string between the
303       backticks is handled as if it were the argument to the "system"
304       operator (see below).  In this case, Perl will wait for the subprocess
305       to complete before continuing.
306
307       The mailbox (MBX) that perl can create to communicate with a pipe
308       defaults to a buffer size of 8192 on 64-bit systems, 512 on VAX.  The
309       default buffer size is adjustable via the logical name PERL_MBX_SIZE
310       provided that the value falls between 128 and the SYSGEN parameter
311       MAXBUF inclusive.  For example, to set the mailbox size to 32767 use
312       "$ENV{'PERL_MBX_SIZE'} = 32767;" and then open and use pipe constructs.
313       An alternative would be to issue the command:
314
315           $ Define PERL_MBX_SIZE 32767
316
317       before running your wide record pipe program.  A larger value may
318       improve performance at the expense of the BYTLM UAF quota.
319

PERL5LIB and PERLLIB

321       The PERL5LIB and PERLLIB logical names work as documented in perl,
322       except that the element separator is '|' instead of ':'.  The directory
323       specifications may use either VMS or Unix syntax.
324

The Perl Forked Debugger

326       The Perl forked debugger places the debugger commands and output in a
327       separate X-11 terminal window so that commands and output from multiple
328       processes are not mixed together.
329
330       Perl on VMS supports an emulation of the forked debugger when Perl is
331       run on a VMS system that has X11 support installed.
332
333       To use the forked debugger, you need to have the default display set to
334       an X-11 Server and some environment variables set that Unix expects.
335
336       The forked debugger requires the environment variable "TERM" to be
337       "xterm", and the environment variable "DISPLAY" to exist.  "xterm" must
338       be in lower case.
339
340         $define TERM "xterm"
341
342         $define DISPLAY "hostname:0.0"
343
344       Currently the value of "DISPLAY" is ignored.  It is recommended that it
345       be set to be the hostname of the display, the server and screen in Unix
346       notation.  In the future the value of DISPLAY may be honored by Perl
347       instead of using the default display.
348
349       It may be helpful to always use the forked debugger so that script I/O
350       is separated from debugger I/O.  You can force the debugger to be
351       forked by assigning a value to the logical name <PERLDB_PIDS> that is
352       not a process identification number.
353
354         $define PERLDB_PIDS XXXX
355

PERL_VMS_EXCEPTION_DEBUG

357       The PERL_VMS_EXCEPTION_DEBUG being defined as "ENABLE" will cause the
358       VMS debugger to be invoked if a fatal exception that is not otherwise
359       handled is raised.  The purpose of this is to allow debugging of
360       internal Perl problems that would cause such a condition.
361
362       This allows the programmer to look at the execution stack and variables
363       to find out the cause of the exception.  As the debugger is being
364       invoked as the Perl interpreter is about to do a fatal exit, continuing
365       the execution in debug mode is usally not practical.
366
367       Starting Perl in the VMS debugger may change the program execution
368       profile in a way that such problems are not reproduced.
369
370       The "kill" function can be used to test this functionality from within
371       a program.
372
373       In typical VMS style, only the first letter of the value of this
374       logical name is actually checked in a case insensitive mode, and it is
375       considered enabled if it is the value "T","1" or "E".
376
377       This logical name must be defined before Perl is started.
378

Command line

380   I/O redirection and backgrounding
381       Perl for VMS supports redirection of input and output on the command
382       line, using a subset of Bourne shell syntax:
383
384       ·   "<file" reads stdin from "file",
385
386       ·   ">file" writes stdout to "file",
387
388       ·   ">>file" appends stdout to "file",
389
390       ·   "2>file" writes stderr to "file",
391
392       ·   "2>>file" appends stderr to "file", and
393
394       ·   "2>&1" redirects stderr to stdout.
395
396       In addition, output may be piped to a subprocess, using the character
397       '|'.  Anything after this character on the command line is passed to a
398       subprocess for execution; the subprocess takes the output of Perl as
399       its input.
400
401       Finally, if the command line ends with '&', the entire command is run
402       in the background as an asynchronous subprocess.
403
404   Command line switches
405       The following command line switches behave differently under VMS than
406       described in perlrun.  Note also that in order to pass uppercase
407       switches to Perl, you need to enclose them in double-quotes on the
408       command line, since the CRTL downcases all unquoted strings.
409
410       On newer 64 bit versions of OpenVMS, a process setting now controls if
411       the quoting is needed to preserve the case of command line arguments.
412
413       -i  If the "-i" switch is present but no extension for a backup copy is
414           given, then inplace editing creates a new version of a file; the
415           existing copy is not deleted.  (Note that if an extension is given,
416           an existing file is renamed to the backup file, as is the case
417           under other operating systems, so it does not remain as a previous
418           version under the original filename.)
419
420       -S  If the "-S" or "-"S"" switch is present and the script name does
421           not contain a directory, then Perl translates the logical name
422           DCL$PATH as a searchlist, using each translation as a directory in
423           which to look for the script.  In addition, if no file type is
424           specified, Perl looks in each directory for a file matching the
425           name specified, with a blank type, a type of .pl, and a type of
426           .com, in that order.
427
428       -u  The "-u" switch causes the VMS debugger to be invoked after the
429           Perl program is compiled, but before it has run.  It does not
430           create a core dump file.
431

Perl functions

433       As of the time this document was last revised, the following Perl
434       functions were implemented in the VMS port of Perl (functions marked
435       with * are discussed in more detail below):
436
437           file tests*, abs, alarm, atan, backticks*, binmode*, bless,
438           caller, chdir, chmod, chown, chomp, chop, chr,
439           close, closedir, cos, crypt*, defined, delete, die, do, dump*,
440           each, endgrent, endpwent, eof, eval, exec*, exists, exit, exp,
441           fileno, flock  getc, getgrent*, getgrgid*, getgrnam, getlogin, getppid,
442           getpwent*, getpwnam*, getpwuid*, glob, gmtime*, goto,
443           grep, hex, ioctl, import, index, int, join, keys, kill*,
444           last, lc, lcfirst, lchown*, length, link*, local, localtime, log, lstat, m//,
445           map, mkdir, my, next, no, oct, open, opendir, ord, pack,
446           pipe, pop, pos, print, printf, push, q//, qq//, qw//,
447           qx//*, quotemeta, rand, read, readdir, readlink*, redo, ref, rename,
448           require, reset, return, reverse, rewinddir, rindex,
449           rmdir, s///, scalar, seek, seekdir, select(internal),
450           select (system call)*, setgrent, setpwent, shift, sin, sleep,
451           socketpair, sort, splice, split, sprintf, sqrt, srand, stat,
452           study, substr, symlink*, sysread, system*, syswrite, tell,
453           telldir, tie, time, times*, tr///, uc, ucfirst, umask,
454           undef, unlink*, unpack, untie, unshift, use, utime*,
455           values, vec, wait, waitpid*, wantarray, warn, write, y///
456
457       The following functions were not implemented in the VMS port, and
458       calling them produces a fatal error (usually) or undefined behavior
459       (rarely, we hope):
460
461           chroot, dbmclose, dbmopen, fork*, getpgrp, getpriority,
462           msgctl, msgget, msgsend, msgrcv, semctl,
463           semget, semop, setpgrp, setpriority, shmctl, shmget,
464           shmread, shmwrite, syscall
465
466       The following functions are available on Perls compiled with Dec C 5.2
467       or greater and running VMS 7.0 or greater:
468
469           truncate
470
471       The following functions are available on Perls built on VMS 7.2 or
472       greater:
473
474           fcntl (without locking)
475
476       The following functions may or may not be implemented, depending on
477       what type of socket support you've built into your copy of Perl:
478
479           accept, bind, connect, getpeername,
480           gethostbyname, getnetbyname, getprotobyname,
481           getservbyname, gethostbyaddr, getnetbyaddr,
482           getprotobynumber, getservbyport, gethostent,
483           getnetent, getprotoent, getservent, sethostent,
484           setnetent, setprotoent, setservent, endhostent,
485           endnetent, endprotoent, endservent, getsockname,
486           getsockopt, listen, recv, select(system call)*,
487           send, setsockopt, shutdown, socket
488
489       The following function is available on Perls built on 64 bit OpenVMS
490       v8.2 with hard links enabled on an ODS-5 formatted build disk.  CRTL
491       support is in principle available as of OpenVMS v7.3-1, and better
492       configuration support could detect this.
493
494           link
495
496       The following functions are available on Perls built on 64 bit OpenVMS
497       v8.2 and later.  CRTL support is in principle available as of OpenVMS
498       v7.3-2, and better configuration support could detect this.
499
500          getgrgid, getgrnam, getpwnam, getpwuid,
501          setgrent, ttyname
502
503       The following functions are available on Perls built on 64 bit OpenVMS
504       v8.2 and later.
505
506          statvfs, socketpair
507
508       File tests
509           The tests "-b", "-B", "-c", "-C", "-d", "-e", "-f", "-o", "-M",
510           "-s", "-S", "-t", "-T", and "-z" work as advertised.  The return
511           values for "-r", "-w", and "-x" tell you whether you can actually
512           access the file; this may not reflect the UIC-based file
513           protections.  Since real and effective UIC don't differ under VMS,
514           "-O", "-R", "-W", and "-X" are equivalent to "-o", "-r", "-w", and
515           "-x".  Similarly, several other tests, including "-A", "-g", "-k",
516           "-l", "-p", and "-u", aren't particularly meaningful under VMS, and
517           the values returned by these tests reflect whatever your CRTL
518           "stat()" routine does to the equivalent bits in the st_mode field.
519           Finally, "-d" returns true if passed a device specification without
520           an explicit directory (e.g. "DUA1:"), as well as if passed a
521           directory.
522
523           There are DECC feature logical names AND ODS-5 volume attributes
524           that also control what values are returned for the date fields.
525
526           Note: Some sites have reported problems when using the file-access
527           tests ("-r", "-w", and "-x") on files accessed via DEC's DFS.
528           Specifically, since DFS does not currently provide access to the
529           extended file header of files on remote volumes, attempts to
530           examine the ACL fail, and the file tests will return false, with $!
531           indicating that the file does not exist.  You can use "stat" on
532           these files, since that checks UIC-based protection only, and then
533           manually check the appropriate bits, as defined by your C
534           compiler's stat.h, in the mode value it returns, if you need an
535           approximation of the file's protections.
536
537       backticks
538           Backticks create a subprocess, and pass the enclosed string to it
539           for execution as a DCL command.  Since the subprocess is created
540           directly via "lib$spawn()", any valid DCL command string may be
541           specified.
542
543       binmode FILEHANDLE
544           The "binmode" operator will attempt to insure that no translation
545           of carriage control occurs on input from or output to this
546           filehandle.  Since this involves reopening the file and then
547           restoring its file position indicator, if this function returns
548           FALSE, the underlying filehandle may no longer point to an open
549           file, or may point to a different position in the file than before
550           "binmode" was called.
551
552           Note that "binmode" is generally not necessary when using normal
553           filehandles; it is provided so that you can control I/O to existing
554           record-structured files when necessary.  You can also use the
555           "vmsfopen" function in the VMS::Stdio extension to gain finer
556           control of I/O to files and devices with different record
557           structures.
558
559       crypt PLAINTEXT, USER
560           The "crypt" operator uses the "sys$hash_password" system service to
561           generate the hashed representation of PLAINTEXT.  If USER is a
562           valid username, the algorithm and salt values are taken from that
563           user's UAF record.  If it is not, then the preferred algorithm and
564           a salt of 0 are used.  The quadword encrypted value is returned as
565           an 8-character string.
566
567           The value returned by "crypt" may be compared against the encrypted
568           password from the UAF returned by the "getpw*" functions, in order
569           to authenticate users.  If you're going to do this, remember that
570           the encrypted password in the UAF was generated using uppercase
571           username and password strings; you'll have to upcase the arguments
572           to "crypt" to insure that you'll get the proper value:
573
574               sub validate_passwd {
575                   my($user,$passwd) = @_;
576                   my($pwdhash);
577                   if ( !($pwdhash = (getpwnam($user))[1]) ||
578                          $pwdhash ne crypt("\U$passwd","\U$name") ) {
579                       intruder_alert($name);
580                   }
581                   return 1;
582               }
583
584       die "die" will force the native VMS exit status to be an SS$_ABORT code
585           if neither of the $! or $? status values are ones that would cause
586           the native status to be interpreted as being what VMS classifies as
587           SEVERE_ERROR severity for DCL error handling.
588
589           When "PERL_VMS_POSIX_EXIT" is active (see "$?" below), the native
590           VMS exit status value will have either one of the $! or $? or $^E
591           or the Unix value 255 encoded into it in a way that the effective
592           original value can be decoded by other programs written in C,
593           including Perl and the GNV package.  As per the normal non-VMS
594           behavior of "die" if either $! or $? are non-zero, one of those
595           values will be encoded into a native VMS status value.  If both of
596           the Unix status values are 0, and the $^E value is set one of ERROR
597           or SEVERE_ERROR severity, then the $^E value will be used as the
598           exit code as is.  If none of the above apply, the Unix value of 255
599           will be encoded into a native VMS exit status value.
600
601           Please note a significant difference in the behavior of "die" in
602           the "PERL_VMS_POSIX_EXIT" mode is that it does not force a VMS
603           SEVERE_ERROR status on exit.  The Unix exit values of 2 through 255
604           will be encoded in VMS status values with severity levels of
605           SUCCESS.  The Unix exit value of 1 will be encoded in a VMS status
606           value with a severity level of ERROR.  This is to be compatible
607           with how the VMS C library encodes these values.
608
609           The minimum severity level set by "die" in "PERL_VMS_POSIX_EXIT"
610           mode may be changed to be ERROR or higher in the future depending
611           on the results of testing and further review.
612
613           See "$?" for a description of the encoding of the Unix value to
614           produce a native VMS status containing it.
615
616       dump
617           Rather than causing Perl to abort and dump core, the "dump"
618           operator invokes the VMS debugger.  If you continue to execute the
619           Perl program under the debugger, control will be transferred to the
620           label specified as the argument to "dump", or, if no label was
621           specified, back to the beginning of the program.  All other state
622           of the program (e.g. values of variables, open file handles) are
623           not affected by calling "dump".
624
625       exec LIST
626           A call to "exec" will cause Perl to exit, and to invoke the command
627           given as an argument to "exec" via "lib$do_command".  If the
628           argument begins with '@' or '$' (other than as part of a filespec),
629           then it is executed as a DCL command.  Otherwise, the first token
630           on the command line is treated as the filespec of an image to run,
631           and an attempt is made to invoke it (using .Exe and the process
632           defaults to expand the filespec) and pass the rest of "exec"'s
633           argument to it as parameters.  If the token has no file type, and
634           matches a file with null type, then an attempt is made to determine
635           whether the file is an executable image which should be invoked
636           using "MCR" or a text file which should be passed to DCL as a
637           command procedure.
638
639       fork
640           While in principle the "fork" operator could be implemented via
641           (and with the same rather severe limitations as) the CRTL "vfork()"
642           routine, and while some internal support to do just that is in
643           place, the implementation has never been completed, making "fork"
644           currently unavailable.  A true kernel "fork()" is expected in a
645           future version of VMS, and the pseudo-fork based on interpreter
646           threads may be available in a future version of Perl on VMS (see
647           perlfork).  In the meantime, use "system", backticks, or piped
648           filehandles to create subprocesses.
649
650       getpwent
651       getpwnam
652       getpwuid
653           These operators obtain the information described in perlfunc, if
654           you have the privileges necessary to retrieve the named user's UAF
655           information via "sys$getuai".  If not, then only the $name, $uid,
656           and $gid items are returned.  The $dir item contains the login
657           directory in VMS syntax, while the $comment item contains the login
658           directory in Unix syntax. The $gcos item contains the owner field
659           from the UAF record.  The $quota item is not used.
660
661       gmtime
662           The "gmtime" operator will function properly if you have a working
663           CRTL "gmtime()" routine, or if the logical name
664           SYS$TIMEZONE_DIFFERENTIAL is defined as the number of seconds which
665           must be added to UTC to yield local time.  (This logical name is
666           defined automatically if you are running a version of VMS with
667           built-in UTC support.)  If neither of these cases is true, a
668           warning message is printed, and "undef" is returned.
669
670       kill
671           In most cases, "kill" is implemented via the undocumented system
672           service $SIGPRC, which has the same calling sequence as $FORCEX,
673           but throws an exception in the target process rather than forcing
674           it to call $EXIT.  Generally speaking, "kill" follows the behavior
675           of the CRTL's "kill()" function, but unlike that function can be
676           called from within a signal handler.  Also, unlike the "kill" in
677           some versions of the CRTL, Perl's "kill" checks the validity of the
678           signal passed in and returns an error rather than attempting to
679           send an unrecognized signal.
680
681           Also, negative signal values don't do anything special under VMS;
682           they're just converted to the corresponding positive value.
683
684       qx//
685           See the entry on "backticks" above.
686
687       select (system call)
688           If Perl was not built with socket support, the system call version
689           of "select" is not available at all.  If socket support is present,
690           then the system call version of "select" functions only for file
691           descriptors attached to sockets.  It will not provide information
692           about regular files or pipes, since the CRTL "select()" routine
693           does not provide this functionality.
694
695       stat EXPR
696           Since VMS keeps track of files according to a different scheme than
697           Unix, it's not really possible to represent the file's ID in the
698           "st_dev" and "st_ino" fields of a "struct stat".  Perl tries its
699           best, though, and the values it uses are pretty unlikely to be the
700           same for two different files.  We can't guarantee this, though, so
701           caveat scriptor.
702
703       system LIST
704           The "system" operator creates a subprocess, and passes its
705           arguments to the subprocess for execution as a DCL command.  Since
706           the subprocess is created directly via "lib$spawn()", any valid DCL
707           command string may be specified.  If the string begins with '@', it
708           is treated as a DCL command unconditionally.  Otherwise, if the
709           first token contains a character used as a delimiter in file
710           specification (e.g. ":" or "]"), an attempt is made to expand it
711           using  a default type of .Exe and the process defaults, and if
712           successful, the resulting file is invoked via "MCR". This allows
713           you to invoke an image directly simply by passing the file
714           specification to "system", a common Unixish idiom.  If the token
715           has no file type, and matches a file with null type, then an
716           attempt is made to determine whether the file is an executable
717           image which should be invoked using "MCR" or a text file which
718           should be passed to DCL as a command procedure.
719
720           If LIST consists of the empty string, "system" spawns an
721           interactive DCL subprocess, in the same fashion as typing SPAWN at
722           the DCL prompt.
723
724           Perl waits for the subprocess to complete before continuing
725           execution in the current process.  As described in perlfunc, the
726           return value of "system" is a fake "status" which follows POSIX
727           semantics unless the pragma "use vmsish 'status'" is in effect; see
728           the description of $? in this document for more detail.
729
730       time
731           The value returned by "time" is the offset in seconds from
732           01-JAN-1970 00:00:00 (just like the CRTL's times() routine), in
733           order to make life easier for code coming in from the POSIX/Unix
734           world.
735
736       times
737           The array returned by the "times" operator is divided up according
738           to the same rules the CRTL "times()" routine.  Therefore, the
739           "system time" elements will always be 0, since there is no
740           difference between "user time" and "system" time under VMS, and the
741           time accumulated by a subprocess may or may not appear separately
742           in the "child time" field, depending on whether times keeps track
743           of subprocesses separately.  Note especially that the VAXCRTL (at
744           least) keeps track only of subprocesses spawned using fork and
745           exec; it will not accumulate the times of subprocesses spawned via
746           pipes, system, or backticks.
747
748       unlink LIST
749           "unlink" will delete the highest version of a file only; in order
750           to delete all versions, you need to say
751
752               1 while unlink LIST;
753
754           You may need to make this change to scripts written for a Unix
755           system which expect that after a call to "unlink", no files with
756           the names passed to "unlink" will exist.  (Note: This can be
757           changed at compile time; if you "use Config" and
758           $Config{'d_unlink_all_versions'} is "define", then "unlink" will
759           delete all versions of a file on the first call.)
760
761           "unlink" will delete a file if at all possible, even if it requires
762           changing file protection (though it won't try to change the
763           protection of the parent directory).  You can tell whether you've
764           got explicit delete access to a file by using the
765           "VMS::Filespec::candelete" operator.  For instance, in order to
766           delete only files to which you have delete access, you could say
767           something like
768
769               sub safe_unlink {
770                   my($file,$num);
771                   foreach $file (@_) {
772                       next unless VMS::Filespec::candelete($file);
773                       $num += unlink $file;
774                   }
775                   $num;
776               }
777
778           (or you could just use "VMS::Stdio::remove", if you've installed
779           the VMS::Stdio extension distributed with Perl). If "unlink" has to
780           change the file protection to delete the file, and you interrupt it
781           in midstream, the file may be left intact, but with a changed ACL
782           allowing you delete access.
783
784           This behavior of "unlink" is to be compatible with POSIX behavior
785           and not traditional VMS behavior.
786
787       utime LIST
788           This operator changes only the modification time of the file (VMS
789           revision date) on ODS-2 volumes and ODS-5 volumes without access
790           dates enabled. On ODS-5 volumes with access dates enabled, the true
791           access time is modified.
792
793       waitpid PID,FLAGS
794           If PID is a subprocess started by a piped "open()" (see open),
795           "waitpid" will wait for that subprocess, and return its final
796           status value in $?.  If PID is a subprocess created in some other
797           way (e.g.  SPAWNed before Perl was invoked), "waitpid" will simply
798           check once per second whether the process has completed, and return
799           when it has.  (If PID specifies a process that isn't a subprocess
800           of the current process, and you invoked Perl with the "-w" switch,
801           a warning will be issued.)
802
803           Returns PID on success, -1 on error.  The FLAGS argument is ignored
804           in all cases.
805

Perl variables

807       The following VMS-specific information applies to the indicated
808       "special" Perl variables, in addition to the general information in
809       perlvar.  Where there is a conflict, this information takes precedence.
810
811       %ENV
812           The operation of the %ENV array depends on the translation of the
813           logical name PERL_ENV_TABLES.  If defined, it should be a search
814           list, each element of which specifies a location for %ENV elements.
815           If you tell Perl to read or set the element "$ENV{"name"}", then
816           Perl uses the translations of PERL_ENV_TABLES as follows:
817
818           CRTL_ENV
819               This string tells Perl to consult the CRTL's internal "environ"
820               array of key-value pairs, using name as the key.  In most
821               cases, this contains only a few keys, but if Perl was invoked
822               via the C "exec[lv]e()" function, as is the case for CGI
823               processing by some HTTP servers, then the "environ" array may
824               have been populated by the calling program.
825
826           CLISYM_[LOCAL]
827               A string beginning with "CLISYM_"tells Perl to consult the
828               CLI's symbol tables, using name as the name of the symbol.
829               When reading an element of %ENV, the local symbol table is
830               scanned first, followed by the global symbol table..  The
831               characters following "CLISYM_" are significant when an element
832               of %ENV is set or deleted: if the complete string is
833               "CLISYM_LOCAL", the change is made in the local symbol table;
834               otherwise the global symbol table is changed.
835
836           Any other string
837               If an element of PERL_ENV_TABLES translates to any other
838               string, that string is used as the name of a logical name
839               table, which is consulted using name as the logical name.  The
840               normal search order of access modes is used.
841
842           PERL_ENV_TABLES is translated once when Perl starts up; any changes
843           you make while Perl is running do not affect the behavior of %ENV.
844           If PERL_ENV_TABLES is not defined, then Perl defaults to consulting
845           first the logical name tables specified by LNM$FILE_DEV, and then
846           the CRTL "environ" array.
847
848           In all operations on %ENV, the key string is treated as if it were
849           entirely uppercase, regardless of the case actually specified in
850           the Perl expression.
851
852           When an element of %ENV is read, the locations to which
853           PERL_ENV_TABLES points are checked in order, and the value obtained
854           from the first successful lookup is returned.  If the name of the
855           %ENV element contains a semi-colon, it and any characters after it
856           are removed.  These are ignored when the CRTL "environ" array or a
857           CLI symbol table is consulted.  However, the name is looked up in a
858           logical name table, the suffix after the semi-colon is treated as
859           the translation index to be used for the lookup.   This lets you
860           look up successive values for search list logical names.  For
861           instance, if you say
862
863              $  Define STORY  once,upon,a,time,there,was
864              $  perl -e "for ($i = 0; $i <= 6; $i++) " -
865              _$ -e "{ print $ENV{'story;'.$i},' '}"
866
867           Perl will print "ONCE UPON A TIME THERE WAS", assuming, of course,
868           that PERL_ENV_TABLES is set up so that the logical name "story" is
869           found, rather than a CLI symbol or CRTL "environ" element with the
870           same name.
871
872           When an element of %ENV is set to a defined string, the
873           corresponding definition is made in the location to which the first
874           translation of PERL_ENV_TABLES points.  If this causes a logical
875           name to be created, it is defined in supervisor mode.  (The same is
876           done if an existing logical name was defined in executive or kernel
877           mode; an existing user or supervisor mode logical name is reset to
878           the new value.)  If the value is an empty string, the logical
879           name's translation is defined as a single NUL (ASCII 00) character,
880           since a logical name cannot translate to a zero-length string.
881           (This restriction does not apply to CLI symbols or CRTL "environ"
882           values; they are set to the empty string.)  An element of the CRTL
883           "environ" array can be set only if your copy of Perl knows about
884           the CRTL's "setenv()" function.  (This is present only in some
885           versions of the DECCRTL; check $Config{d_setenv} to see whether
886           your copy of Perl was built with a CRTL that has this function.)
887
888           When an element of %ENV is set to "undef", the element is looked up
889           as if it were being read, and if it is found, it is deleted.  (An
890           item "deleted" from the CRTL "environ" array is set to the empty
891           string; this can only be done if your copy of Perl knows about the
892           CRTL "setenv()" function.)  Using "delete" to remove an element
893           from %ENV has a similar effect, but after the element is deleted,
894           another attempt is made to look up the element, so an inner-mode
895           logical name or a name in another location will replace the logical
896           name just deleted.  In either case, only the first value found
897           searching PERL_ENV_TABLES is altered.  It is not possible at
898           present to define a search list logical name via %ENV.
899
900           The element $ENV{DEFAULT} is special: when read, it returns Perl's
901           current default device and directory, and when set, it resets them,
902           regardless of the definition of PERL_ENV_TABLES.  It cannot be
903           cleared or deleted; attempts to do so are silently ignored.
904
905           Note that if you want to pass on any elements of the C-local
906           environ array to a subprocess which isn't started by fork/exec, or
907           isn't running a C program, you can "promote" them to logical names
908           in the current process, which will then be inherited by all
909           subprocesses, by saying
910
911               foreach my $key (qw[C-local keys you want promoted]) {
912                   my $temp = $ENV{$key}; # read from C-local array
913                   $ENV{$key} = $temp;    # and define as logical name
914               }
915
916           (You can't just say $ENV{$key} = $ENV{$key}, since the Perl
917           optimizer is smart enough to elide the expression.)
918
919           Don't try to clear %ENV by saying "%ENV = ();", it will throw a
920           fatal error.  This is equivalent to doing the following from DCL:
921
922               DELETE/LOGICAL *
923
924           You can imagine how bad things would be if, for example, the
925           SYS$MANAGER or SYS$SYSTEM logical names were deleted.
926
927           At present, the first time you iterate over %ENV using "keys", or
928           "values",  you will incur a time penalty as all logical names are
929           read, in order to fully populate %ENV.  Subsequent iterations will
930           not reread logical names, so they won't be as slow, but they also
931           won't reflect any changes to logical name tables caused by other
932           programs.
933
934           You do need to be careful with the logical names representing
935           process-permanent files, such as "SYS$INPUT" and "SYS$OUTPUT".  The
936           translations for these logical names are prepended with a two-byte
937           binary value (0x1B 0x00) that needs to be stripped off if you
938           wantto use it. (In previous versions of Perl it wasn't possible to
939           get the values of these logical names, as the null byte acted as an
940           end-of-string marker)
941
942       $!  The string value of $! is that returned by the CRTL's strerror()
943           function, so it will include the VMS message for VMS-specific
944           errors.  The numeric value of $! is the value of "errno", except if
945           errno is EVMSERR, in which case $! contains the value of
946           vaxc$errno.  Setting $!  always sets errno to the value specified.
947           If this value is EVMSERR, it also sets vaxc$errno to 4 (NONAME-F-
948           NOMSG), so that the string value of $! won't reflect the VMS error
949           message from before $! was set.
950
951       $^E This variable provides direct access to VMS status values in
952           vaxc$errno, which are often more specific than the generic Unix-
953           style error messages in $!.  Its numeric value is the value of
954           vaxc$errno, and its string value is the corresponding VMS message
955           string, as retrieved by sys$getmsg().  Setting $^E sets vaxc$errno
956           to the value specified.
957
958           While Perl attempts to keep the vaxc$errno value to be current, if
959           errno is not EVMSERR, it may not be from the current operation.
960
961       $?  The "status value" returned in $? is synthesized from the actual
962           exit status of the subprocess in a way that approximates POSIX
963           wait(5) semantics, in order to allow Perl programs to portably test
964           for successful completion of subprocesses.  The low order 8 bits of
965           $? are always 0 under VMS, since the termination status of a
966           process may or may not have been generated by an exception.
967
968           The next 8 bits contain the termination status of the program.
969
970           If the child process follows the convention of C programs compiled
971           with the _POSIX_EXIT macro set, the status value will contain the
972           actual value of 0 to 255 returned by that program on a normal exit.
973
974           With the _POSIX_EXIT macro set, the Unix exit value of zero is
975           represented as a VMS native status of 1, and the Unix values from 2
976           to 255 are encoded by the equation:
977
978              VMS_status = 0x35a000 + (unix_value * 8) + 1.
979
980           And in the special case of Unix value 1 the encoding is:
981
982              VMS_status = 0x35a000 + 8 + 2 + 0x10000000.
983
984           For other termination statuses, the severity portion of the
985           subprocess's exit status is used: if the severity was success or
986           informational, these bits are all 0; if the severity was warning,
987           they contain a value of 1; if the severity was error or fatal
988           error, they contain the actual severity bits, which turns out to be
989           a value of 2 for error and 4 for severe_error.  Fatal is another
990           term for the severe_error status.
991
992           As a result, $? will always be zero if the subprocess's exit status
993           indicated successful completion, and non-zero if a warning or error
994           occurred or a program compliant with encoding _POSIX_EXIT values
995           was run and set a status.
996
997           How can you tell the difference between a non-zero status that is
998           the result of a VMS native error status or an encoded Unix status?
999           You can not unless you look at the ${^CHILD_ERROR_NATIVE} value.
1000           The ${^CHILD_ERROR_NATIVE} value returns the actual VMS status
1001           value and check the severity bits. If the severity bits are equal
1002           to 1, then if the numeric value for $? is between 2 and 255 or 0,
1003           then $? accurately reflects a value passed back from a Unix
1004           application.  If $? is 1, and the severity bits indicate a VMS
1005           error (2), then $? is from a Unix application exit value.
1006
1007           In practice, Perl scripts that call programs that return
1008           _POSIX_EXIT type status values will be expecting those values, and
1009           programs that call traditional VMS programs will either be
1010           expecting the previous behavior or just checking for a non-zero
1011           status.
1012
1013           And success is always the value 0 in all behaviors.
1014
1015           When the actual VMS termination status of the child is an error,
1016           internally the $! value will be set to the closest Unix errno value
1017           to that error so that Perl scripts that test for error messages
1018           will see the expected Unix style error message instead of a VMS
1019           message.
1020
1021           Conversely, when setting $? in an END block, an attempt is made to
1022           convert the POSIX value into a native status intelligible to the
1023           operating system upon exiting Perl.  What this boils down to is
1024           that setting $? to zero results in the generic success value
1025           SS$_NORMAL, and setting $? to a non-zero value results in the
1026           generic failure status SS$_ABORT.  See also "exit" in perlport.
1027
1028           With the "PERL_VMS_POSIX_EXIT" logical name defined as "ENABLE",
1029           setting $? will cause the new value to be encoded into $^E so that
1030           either the original parent or child exit status values
1031            0 to 255 can be automatically recovered by C programs expecting
1032           _POSIX_EXIT behavior.  If both a parent and a child exit value are
1033           non-zero, then it will be assumed that this is actually a VMS
1034           native status value to be passed through.  The special value of
1035           0xFFFF is almost a NOOP as it will cause the current native VMS
1036           status in the C library to become the current native Perl VMS
1037           status, and is handled this way as it is known to not be a valid
1038           native VMS status value.  It is recommend that only values in the
1039           range of normal Unix parent or child status numbers, 0 to 255 are
1040           used.
1041
1042           The pragma "use vmsish 'status'" makes $? reflect the actual VMS
1043           exit status instead of the default emulation of POSIX status
1044           described above.  This pragma also disables the conversion of non-
1045           zero values to SS$_ABORT when setting $? in an END block (but zero
1046           will still be converted to SS$_NORMAL).
1047
1048           Do not use the pragma "use vmsish 'status'" with
1049           "PERL_VMS_POSIX_EXIT" enabled, as they are at times requesting
1050           conflicting actions and the consequence of ignoring this advice
1051           will be undefined to allow future improvements in the POSIX exit
1052           handling.
1053
1054           In general, with "PERL_VMS_POSIX_EXIT" enabled, more detailed
1055           information will be availble in the exit status for DCL scripts or
1056           other native VMS tools, and will give the expected information for
1057           Posix programs.  It has not been made the default in order to
1058           preserve backward compatibility.
1059
1060           N.B. Setting "DECC$FILENAME_UNIX_REPORT" implicitly enables
1061           "PERL_VMS_POSIX_EXIT".
1062
1063       $|  Setting $| for an I/O stream causes data to be flushed all the way
1064           to disk on each write (i.e. not just to the underlying RMS buffers
1065           for a file).  In other words, it's equivalent to calling fflush()
1066           and fsync() from C.
1067

Standard modules with VMS-specific differences

1069   SDBM_File
1070       SDBM_File works properly on VMS. It has, however, one minor difference.
1071       The database directory file created has a .sdbm_dir extension rather
1072       than a .dir extension. .dir files are VMS filesystem directory files,
1073       and using them for other purposes could cause unacceptable problems.
1074

Revision date

1076       Please see the git repository for revision history.
1077

AUTHOR

1079       Charles Bailey  bailey@cor.newman.upenn.edu Craig Berry
1080       craigberry@mac.com Dan Sugalski  dan@sidhe.org John Malmberg
1081       wb8tyw@qsl.net
1082
1083
1084
1085perl v5.12.4                      2011-06-07                        PERLVMS(1)
Impressum