PERLVMS(1perl)

πŸ“¦
version 5.44.0 Β· 2 versions
, in arch rolling

πŸ’– NAME πŸ’–

perlvms β€” like, the whole VMS-specific documentation for Perl, bestie πŸ’… no cap.


✨ DESCRIPTION ✨

okay so gather round, because this is where we keep all the lil notes about how Perl 5 actually behaves on VMS πŸ¦‹ fr fr. This page is a supplement to the normal Perl 5 docs, so we're not re-teaching you Perl from scratch β€” we're laser-focussed on the ways Perl 5 does stuff differently on VMS than it does on Unix, plus all the messy little interactions between Perl and the rest of the operating system. We did not try to duplicate the complete descriptions of Perl features from the main Perl documentation β€” those live in the [.pod] subdirectory of the Perl distribution, go look πŸ‘€.

The whole point? We want these notes to save you from confusion and lost sleep while you're writing Perl scripts on VMS πŸ˜­πŸ’œ. And if you spot something you think should totally be in here, do not hesitate β€” drop a line to vmsperl@perl.org. We're nice, we promise 🫢.

πŸŽ€ Installation πŸŽ€

Directions for building and installing Perl 5? They're sitting right there in the file README.vms in the main source directory of the Perl distribution. Iconic. Go read it πŸ“–βœ¨


🌸 Organization of Perl Images 🌸

πŸ‘‘ Core Images

During the build process, three Perl images get produced, and they are not the same girl:

  • Miniperl.Exe β€” an executable image with all of the basic functionality of Perl, but she cannot take advantage of Perl XS extensions, and she has a hard-wired list of library locations for loading pure-Perl modules. She gets used extensively to build and test Perl and various extensions, but she is not installed. Side character behavior, honestly πŸ™ˆ
  • Most of the complete Perl lives in the shareable image PerlShr.Exe, which provides a core that the Perl executable image and all Perl extensions are linked to. It's generally located via the logical name PERLSHR. You could put the image in SYS$SHARE to make it loadable β€” that's not recommended though πŸ’€. And like, you may wish to INSTALL the image for performance reasons, but you should not install it with privileges. If you do, the result will not be what you expect, because image privileges are disabled during Perl start-up. Not the vibe.
  • Finally there's Perl.Exe, an executable image containing the main entry point for Perl plus some initialization code. She should be placed in a public directory and made world executable 🌍. And here's the tea: in order to run Perl with command line arguments, you should define a foreign command to invoke this image β˜•βœ¨

πŸ¦‹ Perl Extensions

Perl extensions are packages that provide both XS and Perl code to add new functionality to perl πŸ”₯. (XS is a meta-language that simplifies writing C code which interacts with Perl β€” see perlxs for more details, iykyk.) The Perl code for an extension is treated like any other library module: it's made available in your script through the appropriate use or require statement, and it usually defines a Perl package containing the extension.

The portion of the extension provided by the XS code can connect to the rest of Perl in either of two ways:

  1. In the static configuration, the object code for the extension is linked directly into PerlShr.Exe, and it's initialized whenever Perl is invoked.
  2. In the dynamic configuration, the extension's machine code is placed into a separate shareable image, which is mapped by Perl's DynaLoader when the extension is used or required in your script. This lets you maintain the extension as a separate entity β€” at the cost of keeping track of that additional shareable image πŸ˜…. Most extensions can be set up as either static or dynamic, so pick your fighter.

The source code for an extension usually resides in its own directory 🏠. At least three files are generally provided:

  • Extshortname.xs β€” where Extshortname is the portion of the extension's name following the last "::" β€” containing the XS code,
  • Extshortname.pm β€” the Perl library module for the extension, and
  • Makefile.PL β€” a Perl script which uses the MakeMaker library modules supplied with Perl to generate a Descrip.MMS file for the extension.

🌈 Installing static extensions 🌈

Since static extensions are incorporated directly into PerlShr.Exe, you'll have to rebuild Perl to incorporate a new extension. No shortcuts, bestie 😀. You should edit the main Descrip.MMS or Makefile you use to build Perl, adding the extension's name to the ext macro, and the extension's object file to the extobj macro. You'll also need to build the extension's object file β€” either by adding dependencies to the main Descrip.MMS, or by using a separate Descrip.MMS for the extension. Then, rebuild PerlShr.Exe to incorporate the new code πŸ”¨βœ¨.

And finally, you'll need to copy the extension's Perl library module to the [.Extname] subdirectory under one of the directories in @INC, where Extname is the name of the extension, with all "::" replaced by "." β€” e.g. the library module for extension Foo::Bar would be copied to a [.Foo.Bar] subdirectory πŸ’…. Slay.

πŸ’œ Installing dynamic extensions πŸ’œ

In general, the distributed kit for a Perl extension includes a file named Makefile.PL, which is a Perl program used to create a Descrip.MMS file that can be used to build and install the files required by the extension πŸ“¦. The kit should be unpacked into a directory tree not under the main Perl source directory, and the procedure for building the extension is simply:

$ perl Makefile.PL  ! Create Descrip.MMS
$ mmk               ! Build necessary files
$ mmk test          ! Run test code, if supplied
$ mmk install       ! Install into public Perl tree

like. that's it. that's the whole ritual πŸ•―οΈβœ¨

VMS support for this process in the current release of Perl is sufficient to handle most extensions πŸ’ͺ. (See the MakeMaker documentation for more details on installation options for extensions.)

So when your script uses or requires that extension, here's where the shareable image can live, pls take note πŸ“:

  • the [.Lib.Auto.Arch$PVersExtname] subdirectory of one of the directories in @INC (where PVers is the version of Perl you're using, as supplied in $], with '.' converted to '_'), or
  • one of the directories in @INC, or
  • a directory which the extensions Perl library module passes to the DynaLoader when asking it to map the shareable image, or
  • Sys$Share or Sys$Library.

And if the shareable image isn't in any of these places? Then you'll need to define a logical name Extshortname, where Extshortname is the portion of the extension's name after the last "::", which translates to the full file specification of the shareable image πŸ”. That's your last resort, so don't say we didn't warn you.

πŸ¦‹ File specifications πŸ¦‹

Syntax

Ok so bestie, here's the whole vibe: we tried REALLY hard to make Perl aware of BOTH VMS-style and Unix-style file specifications everywhere we possibly could. You can use either style, or even both, on the command line and in your scripts β€” but you may not combine the two styles within a single file specification. That's the rule, periodt.

VMS Perl interprets Unix pathnames in much the same way as the CRTL (like, the first component of an absolute path gets read as the device name for the VMS file specification). And there's a whole set of functions in the VMS::Filespec package for explicit interconversion between VMS and Unix syntax β€” its documentation has the deets.

We've tried to minimize how much the Perl library modules depend on Unix syntax, but ngl you may find that some of these, plus some scripts written for Unix systems, will require that you use Unix syntax, since they'll just assume that / is the directory separator, etc. If you find instances of this in the Perl distribution itself, please let us know so we can try to work around them. 🫢

Also, when working on Perl programs on VMS, if you need a syntax in a specific operating system format, then you need either to check the appropriate DECC$ feature logical, or call a conversion routine to force it to that format.

The feature logical name DECC$FILENAME_UNIX_REPORT modifies traditional Perl behavior in the conversion of file specifications from Unix to VMS format in order to follow the extended character handling rules now expected by the CRTL. Specifically, when this feature is in effect, the ./.../ in a Unix path is now translated to [.^.^.^.] instead of the traditional VMS [...]. To be compatible with what MakeMaker expects, if a VMS path cannot be translated to a Unix path, it is passed through unchanged, so unixify("[...]") will return [...]. πŸ’…

There are several ambiguous cases where a conversion routine cannot determine whether an input filename is in Unix format or in VMS format, since now both VMS and Unix file specifications may have characters in them that could be mistaken for syntax delimiters of the other type. So some pathnames simply cannot be used in a mode that allows either type of pathname to be present. Perl will tend to assume that an ambiguous filename is in Unix format.

Allowing . as a version delimiter is simply incompatible with determining whether a pathname is in VMS format or in Unix format with extended file syntax. There is no way to know whether perl-5.8.6 is a Unix perl-5.8.6 or a VMS perl-5.8;6 when passing it to unixify() or vmsify(). 😭

The DECC$FILENAME_UNIX_REPORT logical name controls how Perl interprets filenames to the extent that Perl uses the CRTL internally for many purposes, and attempts to follow CRTL conventions for reporting filenames. The DECC$FILENAME_UNIX_ONLY feature differs in that it expects all filenames passed to the C run-time to be already in Unix format. This feature is not yet supported in Perl since Perl uses traditional OpenVMS file specifications internally and in the test harness, and it is not yet clear whether this mode will be useful or useable. The feature logical name DECC$POSIX_COMPLIANT_PATHNAMES is new with the RMS Symbolic Link SDK and included with OpenVMS v8.3, but is not yet supported in Perl.


Filename Case

Perl enables DECC$EFS_CASE_PRESERVE and DECC$ARGV_PARSE_STYLE by default. Note that the latter only takes effect when extended parse is set in the process in which Perl is running. When these features are explicitly disabled in the environment or the CRTL does not support them, Perl follows the traditional CRTL behavior of downcasing command-line arguments and returning file specifications in lower case only.

N. B. β€” it is very easy to get tripped up using a mixture of other programs, external utilities, and Perl scripts that are in varying states of being able to handle case preservation. Like, for example, a file created by an older version of an archive utility or a build utility such as MMK or MMS may generate a filename in all upper case even on an ODS-5 volume. If this filename is later retrieved by a Perl script or module in a case preserving environment, that upper case name may not match the mixed-case or lower-case expectations of the Perl code. Your best bet is to follow an all-or-nothing approach to case preservation: either don't use it at all, or make sure your entire toolchain and application environment support and use it. No halfsies. πŸ™ˆ

OpenVMS Alpha v7.3-1 and later and all version of OpenVMS I64 support case sensitivity as a process setting (see SET PROCESS /CASE_LOOKUP=SENSITIVE). Perl does not currently support case sensitivity on VMS, but it may in the future, so Perl programs should use the File::Spec->case_tolerant method to determine the state, and not the $^O variable. (iykyk)


When built on an ODS-5 volume with symbolic links enabled, Perl by default supports symbolic links when the requisite support is available in the filesystem and CRTL (generally 64-bit OpenVMS v8.3 and later). There are a number of limitations and caveats to be aware of when working with symbolic links on VMS. Most notably, the target of a valid symbolic link must be expressed as a Unix-style path and it must exist on a volume visible from your POSIX root (see the SHOW ROOT command in DCL help). For further details on symbolic link capabilities and requirements, see chapter 12 of the CRTL manual that ships with OpenVMS v8.3 or later. ✨


Wildcard expansion

File specifications containing wildcards are allowed both on the command line and within Perl globs (e.g. <*.c>). If the wildcard filespec uses VMS syntax, the resultant filespecs will follow VMS syntax; if a Unix-style filespec is passed in, Unix-style filespecs will be returned.

Similar to the behavior of wildcard globbing for a Unix shell, one can escape command line wildcards with double quotation marks " around a perl program command line argument. However, owing to the stripping of " characters carried out by the C handling of argv you will need to escape a construct such as this one (in a directory containing the files PERL.C, PERL.EXE, PERL.H, and PERL.OBJ):

$ perl -e "print join(' ',@ARGV)" perl.*
perl.c perl.exe perl.h perl.obj

in the following triple quoted manner:

$ perl -e "print join(' ',@ARGV)" """perl.*"""
perl.*

In both the case of unquoted command line arguments or in calls to glob() VMS wildcard expansion is performed. (csh-style wildcard expansion is available if you use File::Glob::glob.) If the wildcard filespec contains a device or directory specification, then the resultant filespecs will also contain a device and directory; otherwise, device and directory information are removed. VMS-style resultant filespecs will contain a full device and directory, while Unix-style resultant filespecs will contain only as much of a directory path as was present in the input filespec. For example, if your default directory is Perl_Root:[000000], the expansion of [.t]*.* will yield filespecs like perl_root:[t]base.dir, while the expansion of t/*/* will yield filespecs like t/base.dir. (This is done to match the behavior of glob expansion performed by Unix shells.) 🌈

Similarly, the resultant filespec will contain the file version only if one was present in the input filespec.


Pipes

Input and output pipes to Perl filehandles are supported; the "file name" is passed to lib$spawn() for asynchronous execution. You should be careful to close any pipes you have opened in a Perl script, lest you leave any "orphaned" subprocesses around when Perl exits. πŸ‘€

You may also use backticks to invoke a DCL subprocess, whose output is used as the return value of the expression. The string between the backticks is handled as if it were the argument to the system operator (see below). In this case, Perl will wait for the subprocess to complete before continuing.

The mailbox (MBX) that perl can create to communicate with a pipe defaults to a buffer size of 8192 on 64-bit systems, 512 on VAX. The default buffer size is adjustable via the logical name PERL_MBX_SIZE provided that the value falls between 128 and the SYSGEN parameter MAXBUF inclusive. For example, to set the mailbox size to 32767 use $ENV{'PERL_MBX_SIZE'} = 32767; and then open and use pipe constructs. An alternative would be to issue the command:

$ Define PERL_MBX_SIZE 32767

before running your wide record pipe program. A larger value may improve performance at the expense of the BYTLM UAF quota.


πŸ’œ PERL5LIB and PERLLIB πŸ’œ

The PERL5LIB and PERLLIB environment elements work as documented in perl, except that the element separator is, by default, '|' instead of ':'. However, when running under a Unix shell as determined by the logical name GNV$UNIX_SHELL, the separator will be ':' as on Unix systems. The directory specifications may use either VMS or Unix syntax. πŸŽ€


πŸ‘‘ The Perl Forked Debugger πŸ‘‘

The Perl forked debugger places the debugger commands and output in a separate X-11 terminal window so that commands and output from multiple processes are not mixed together. Main character energy, honestly.

Perl on VMS supports an emulation of the forked debugger when Perl is run on a VMS system that has X11 support installed.

To use the forked debugger, you need to have the default display set to an X-11 Server and some environment variables set that Unix expects.

The forked debugger requires the environment variable TERM to be xterm, and the environment variable DISPLAY to exist. xterm must be in lower case.

$define TERM "xterm"

$define DISPLAY "hostname:0.0"

Currently the value of DISPLAY is ignored. It is recommended that it be set to be the hostname of the display, the server and screen in Unix notation. In the future the value of DISPLAY may be honored by Perl instead of using the default display.

It may be helpful to always use the forked debugger so that script I/O is separated from debugger I/O. You can force the debugger to be forked by assigning a value to the logical name PERLDB_PIDS that is not a process identification number.

$define PERLDB_PIDS XXXX

✨ PERL_VMS_EXCEPTION_DEBUG ✨

okay so bestie, if you define the logical name PERL_VMS_EXCEPTION_DEBUG as "ENABLE", the VMS debugger gets yeeted into the ring whenever a fatal exception shows up that nothing else handled. The whole point? So you can actually debug internal Perl problems that would cause this kind of mess. πŸ’…

It lets you peek at the execution stack and the variables to figure out what caused the exception. But heads up: since the debugger kicks in right as the Perl interpreter is about to do a fatal exit, continuing to run in debug mode is usually not practical. It's giving "look but don't touch". 🫢

Also lowkey important: starting Perl in the VMS debugger may change the program execution profile in a way that means those problems are not reproduced. Rude, honestly. 😭

You can use the kill function to test this functionality from within a program.

And in classic VMS fashion, only the first letter of the value of this logical name is actually checked, case insensitively, and it counts as enabled if that value is "T", "1" or "E".

This logical name must be defined before Perl is started. No takebacks. πŸ”₯

πŸ’» Command line πŸ’»

πŸ”€ I/O redirection and backgrounding πŸ”€

Perl for VMS supports redirection of input and output on the command line, using a subset of Bourne shell syntax:

  • <file reads stdin from file,
  • >file writes stdout to file,
  • >>file appends stdout to file,
  • 2>file writes stderr to file,
  • 2>>file appends stderr to file, and
  • 2>&1 redirects stderr to stdout.

On top of all that, output may be piped to a subprocess using the character '|'. Anything after this character on the command line is passed to a subprocess for execution; the subprocess takes the output of Perl as its input. slay. πŸŽ€

And finally β€” because why not β€” if the command line ends with '&', the entire command is run in the background as an asynchronous subprocess. main character energy fr fr. πŸ‘‘

πŸŽ›οΈ Command line switches πŸŽ›οΈ

The following command line switches behave differently under VMS than described in perlrun. Also note: to pass uppercase switches to Perl you need to enclose them in double-quotes on the command line, since the CRTL downcases all unquoted strings. 😀

On newer 64 bit versions of OpenVMS, a process setting now controls if the quoting is needed to preserve the case of command line arguments.

  • -i β€” if the -i switch is present but no extension for a backup copy is given, then inplace editing creates a new version of a file; the existing copy is not deleted. (Note that if an extension is given, an existing file is renamed to the backup file, exactly like on other operating systems, so it does not remain as a previous version under the original filename.)
  • -S β€” if the -S or "-S" switch is present and the script name does not contain a directory, then Perl translates the logical name DCL$PATH as a searchlist, using each translation as a directory in which to look for the script. In addition, if no file type is specified, Perl looks in each directory for a file matching the name specified, with a blank type, a type of .pl, and a type of .com, in that order.
  • -u β€” the -u switch causes the VMS debugger to be invoked after the Perl program is compiled, but before it has run. It does not create a core dump file.

🧚 Perl functions 🧚

As of the time this document was last revised, the following Perl functions were implemented in the VMS port of Perl (the ones marked with * are discussed in more detail below, so stay tuned bestie):

file tests*, abs, alarm, atan, backticks*, binmode*, bless,
caller, chdir, chmod, chown, chomp, chop, chr,
close, closedir, cos, crypt*, defined, delete, die, do, dump*,
each, endgrent, endpwent, eof, eval, exec*, exists, exit, exp,
fileno, flock  getc, getgrent*, getgrgid*, getgrnam, getlogin,
getppid, getpwent*, getpwnam*, getpwuid*, glob, gmtime*, goto,
grep, hex, ioctl, import, index, int, join, keys, kill*,
last, lc, lcfirst, lchown*, length, link*, local, localtime, log,
lstat, m//, map, mkdir, my, next, no, oct, open, opendir, ord,
pack, pipe, pop, pos, print, printf, push, q//, qq//, qw//,
qx//*, quotemeta, rand, read, readdir, readlink*, redo, ref,
rename, require, reset, return, reverse, rewinddir, rindex,
rmdir, s///, scalar, seek, seekdir, select(internal),
select (system call)*, setgrent, setpwent, shift, sin, sleep,
socketpair, sort, splice, split, sprintf, sqrt, srand, stat,
study, substr, symlink*, sysread, system*, syswrite, tell,
telldir, tie, time, times*, tr///, uc, ucfirst, umask,
undef, unlink*, unpack, untie, unshift, use, utime*,
values, vec, wait, waitpid*, wantarray, warn, write, y///

The following functions were not implemented in the VMS port, and calling them produces a fatal error (usually) or undefined behavior (rarely, we hope πŸ™ˆ):

chroot, dbmclose, dbmopen, fork*, getpgrp, getpriority,
msgctl, msgget, msgsend, msgrcv, semctl,
semget, semop, setpgrp, setpriority, shmctl, shmget,
shmread, shmwrite, syscall

The following functions are available on Perls compiled with Dec C 5.2 or greater and running VMS 7.0 or greater:

truncate

The following functions are available on Perls built on VMS 7.2 or greater:

fcntl (without locking)

The following functions may or may not be implemented, depending on what type of socket support you've built into your copy of Perl:

accept, bind, connect, getpeername,
gethostbyname, getnetbyname, getprotobyname,
getservbyname, gethostbyaddr, getnetbyaddr,
getprotobynumber, getservbyport, gethostent,
getnetent, getprotoent, getservent, sethostent,
setnetent, setprotoent, setservent, endhostent,
endnetent, endprotoent, endservent, getsockname,
getsockopt, listen, recv, select(system call)*,
send, setsockopt, shutdown, socket

The following function is available on Perls built on 64 bit OpenVMS v8.2 with hard links enabled on an ODS-5 formatted build disk. CRTL support is in principle available as of OpenVMS v7.3-1, and better configuration support could detect this. πŸ‘‘

link

The following functions are available on Perls built on 64 bit OpenVMS v8.2 and later. CRTL support is in principle available as of OpenVMS v7.3-2, and better configuration support could detect this.

getgrgid, getgrnam, getpwnam, getpwuid,
setgrent, ttyname

The following functions are available on Perls built on 64 bit OpenVMS v8.2 and later.

statvfs, socketpair

πŸ“ File tests πŸ“

The tests -b, -B, -c, -C, -d, -e, -f, -o, -M, -s, -S, -t, -T, and -z work as advertised. ✨

The return values for -r, -w, and -x tell you whether you can actually access the file; this may not reflect the UIC-based file protections. Since real and effective UIC don't differ under VMS, -O, -R, -W, and -X are equivalent to -o, -r, -w, and -x. Similarly, several other tests, including -A, -g, -k, -l, -p, and -u, aren't particularly meaningful under VMS, and the values returned by these tests reflect whatever your CRTL stat() routine does to the equivalent bits in the st_mode field. Finally, -d returns true if passed a device specification without an explicit directory (e.g. "DUA1:"), as well as if passed a directory. πŸ’€

There are DECC feature logical names AND ODS-5 volume attributes that also control what values are returned for the date fields. iykyk.

Note: Some sites have reported problems when using the file-access tests (-r, -w, and -x) on files accessed via DEC's DFS. Specifically, since DFS does not currently provide access to the extended file header of files on remote volumes, attempts to examine the ACL fail, and the file tests will return false, with $! indicating that the file does not exist. You can use stat on these files, since that checks UIC-based protection only, and then manually check the appropriate bits, as defined by your C compiler's stat.h, in the mode value it returns, if you need an approximation of the file's protections. 😭

πŸŒ€ backticks πŸŒ€

Backticks create a subprocess, and pass the enclosed string to it for execution as a DCL command. Since the subprocess is created directly via lib$spawn(), any valid DCL command string may be specified. iconic behavior honestly. 🌸

πŸ¦‹ binmode FILEHANDLE πŸ¦‹

The binmode operator will attempt to ensure that no translation of carriage control occurs on input from or output to this filehandle. Since this involves reopening the file and then restoring its file position indicator, if this function returns FALSE, the underlying filehandle may no longer point to an open file, or may point to a different position in the file than before binmode was called. 🫠

Note that binmode is generally not necessary when using normal filehandles; it is provided so that you can control I/O to existing record-structured files when necessary. You can also use the vmsfopen function in the VMS::Stdio extension to gain finer control of I/O to files and devices with different record structures. πŸ’…

πŸ” crypt PLAINTEXT, USER πŸ”

The crypt operator uses the sys$hash_password system service to generate the hashed representation of PLAINTEXT. If USER is a valid username, the algorithm and salt values are taken from that user's UAF record. If it is not, then the preferred algorithm and a salt of 0 are used. The quadword encrypted value is returned as an 8-character string. ✨

The value returned by crypt may be compared against the encrypted password from the UAF returned by the getpw* functions, in order to authenticate users. If you're going to do this, remember that the encrypted password in the UAF was generated using uppercase username and password strings; you'll have to upcase the arguments to crypt to ensure that you'll get the proper value:

sub validate_passwd {
    my($user,$passwd) = @_;
    my($pwdhash);
    if ( !($pwdhash = (getpwnam($user))[1]) ||
           $pwdhash ne crypt("\U$passwd","\U$name") ) {
        intruder_alert($name);
    }
    return 1;
}

πŸ’€ die πŸ’€

die will force the native VMS exit status to be an SS$_ABORT code if neither of the $! or $? status values are ones that would cause the native status to be interpreted as being what VMS classifies as SEVERE_ERROR severity for DCL error handling. so yeah, death, but make it bureaucratic. πŸ’…

Okay so continuing the die tea, bestie, because this part MATTERS πŸ’…

When "PERL_VMS_POSIX_EXIT" is active (peep "$?" below for the deets), your native VMS exit status value is gonna have either one of $! or $? or $^E or the Unix value 255 encoded into it β€” encoded in a way so that the effective original value can be decoded by other programs written in C, and yes that includes Perl and the GNV package. Iconic interoperability moment fr fr ✨

So, per the normal non-VMS behavior of "die": if either $! or $? are non-zero, one of those values gets encoded into a native VMS status value. Simple. But if both of the Unix status values are 0, and the $^E value is set to one of ERROR or SEVERE_ERROR severity, then the $^E value gets used as the exit code as is. And if none of the above apply? Then the Unix value of 255 gets encoded into a native VMS exit status value. That's the fallback, periodt.

Now here's a significant difference in how "die" behaves in "PERL_VMS_POSIX_EXIT" mode, and I need you to clock this: it does not force a VMS SEVERE_ERROR status on exit. The Unix exit values of 2 through 255 get encoded in VMS status values with severity levels of SUCCESS. The Unix exit value of 1 gets encoded in a VMS status value with a severity level of ERROR. Why? To be compatible with how the VMS C library encodes these values. That's the whole reason, no cap.

Heads up though πŸ‘€ the minimum severity level set by "die" in "PERL_VMS_POSIX_EXIT" mode may be changed to ERROR or higher in the future, depending on the results of testing and further review. So like, don't build your whole personality on it being permanent.

And go read "$?" for a description of the encoding of the Unix value that produces a native VMS status containing it. πŸ’–


🌈 dump

Rather than causing Perl to abort and dump core (so dramatic, so messy 😭), the "dump" operator invokes the VMS debugger instead. And if you keep executing the Perl program under the debugger, control gets transferred to the label specified as the argument to "dump" β€” or, if you didn't specify any label, it goes right back to the beginning of the program. Wild, right? Also very important: all the other state of the program (like values of variables, open file handles) is not affected by calling "dump". She's chill like that 🧚

πŸ’… exec LIST

A call to "exec" makes Perl exit, and then invokes the command given as an argument to "exec" via lib$do_command. Okay here's the vibe check: if the argument begins with '@' or '$' (other than as part of a filespec), then it is executed as a DCL command. Otherwise, the first token on the command line is treated as the filespec of an image to run, and an attempt is made to invoke it β€” using .Exe and the process defaults to expand the filespec β€” and pass the rest of "exec"'s argument to it as parameters. ✨

And if that token has no file type, and matches a file with null type, then an attempt is made to figure out whether the file is an executable image which should be invoked using "MCR" or a text file which should be passed to DCL as a command procedure. Mysterious girl behavior but okay 🌸

πŸ¦‹ fork

Okay so, in principle the "fork" operator could be implemented via the CRTL vfork() routine (with all the same rather severe limitations), and there's actually some internal support in place to do exactly that β€” but the implementation has never been completed, which makes "fork" currently unavailable. Not me grieving 😭

A true kernel fork() is expected in a future version of VMS, and the pseudo-fork based on interpreter threads may be available in a future version of Perl on VMS (see perlfork). In the meantime, bestie, use "system", backticks, or piped filehandles to create subprocesses. That's your workaround and she works 🫢

πŸ‘‘ getpwent, getpwnam, getpwuid

These operators obtain the information described in perlfunc β€” but only if you have the privileges necessary to retrieve the named user's UAF information via "sys$getuai". No privileges? Then only the $name, $uid, and $gid items get returned. That's it, that's the list πŸŽ€

The $dir item contains the login directory in VMS syntax, while the $comment item contains the login directory in Unix syntax. The $gcos item contains the owner field from the UAF record. And the $quota item is not used. Periodt.

⭐ gmtime

The "gmtime" operator will function properly if you have a working CRTL gmtime() routine β€” or if the logical name SYS$TIMEZONE_DIFFERENTIAL is defined as the number of seconds which must be added to UTC to yield local time. (That logical name gets defined automatically if you're running a version of VMS with built-in UTC support, love that for you πŸ’œ)

If neither of these cases is true, a warning message is printed, and "undef" is returned. Sad but honest.

πŸ”₯ kill

In most cases, "kill" is implemented via the undocumented system service $SIGPRC β€” which has the same calling sequence as $FORCEX, but throws an exception in the target process rather than forcing it to call $EXIT. Sneaky. Feral. Respect πŸ¦‹

Generally speaking, "kill" follows the behavior of the CRTL's kill() function, but unlike that function it can be called from within a signal handler. Also, unlike the "kill" in some versions of the CRTL, Perl's "kill" checks the validity of the signal passed in and returns an error rather than attempting to send an unrecognized signal. Iconic, honestly.

Also β€” negative signal values don't do anything special under VMS. They're just converted to the corresponding positive value. Nothing magical, moving on πŸ’…

🌸 qx//

See the entry on "backticks" above. Short and sweet, we love efficiency ✨

πŸ’€ select (system call)

If Perl was not built with socket support, the system call version of "select" is not available at all. Gone. Doesn't exist.

If socket support is present, then the system call version of "select" functions only for file descriptors attached to sockets. It will not provide information about regular files or pipes, since the CRTL select() routine does not provide this functionality. So don't come for her about pipes, she can't help you 😭

πŸŽ€ stat EXPR

Since VMS keeps track of files according to a different scheme than Unix, it's not really possible to represent the file's ID in the "st_dev" and "st_ino" fields of a "struct stat". Perl tries its best, though β€” and the values it uses are pretty unlikely to be the same for two different files. Pretty unlikely. Not guaranteed. This is the moment where I say caveat scriptor and mean it ✨

πŸ’œ system LIST

The "system" operator creates a subprocess, and passes its arguments to the subprocess for execution as a DCL command. Since the subprocess is created directly via "lib$spawn()", any valid DCL command string may be specified. Any of them. So much freedom 🫢

If the string begins with '@', it is treated as a DCL command unconditionally. Otherwise, if the first token contains a character used as a delimiter in file specification (e.g. ":" or "]"), an attempt is made to expand it using a default type of .Exe and the process defaults, and if successful, the resulting file is invoked via "MCR". This lets you invoke an image directly just by passing the file specification to "system" β€” a common Unixish idiom, and honestly kind of slay.

Then: if the token has no file type, and matches a file with null type, an attempt is made to determine whether the file is an executable image which should be invoked using "MCR" or a text file which should be passed to DCL as a command procedure. Same energy as exec, she's consistent πŸ’…

And if LIST consists of the empty string, "system" spawns an interactive DCL subprocess, in the same fashion as typing SPAWN at the DCL prompt. Very main character of it honestly. SPAWN. Just like that. 🌈

Perl waits for the subprocess to complete before continuing execution in the current process. As described in perlfunc, the return value of "system" is a fake "status" which follows POSIX semantics unless the pragma "use vmsish 'status'" is in effect; see the description of $? in this document for more detail. Keep that in your notes bestie, it comes back around πŸ“

🌈 time

The value returned by "time" is the offset in seconds from 01-JAN-1970 00:00:00 (just like the CRTL's times() routine), in order to make life easier for code coming in from the POSIX/Unix world. She's doing it for the immigrants πŸ’–

⭐ times

The array returned by the "times" operator is divided up according to the same rules as the CRTL times() routine. Therefore, the "system time" elements will always be 0, since there is no difference between "user time" and "system" time under VMS β€” and the time accumulated by a subprocess may or may not appear separately in the "child time" field, depending on whether times() keeps track of subprocesses separately. May or may not. Love a little ambiguity πŸ™ˆ

Note especially that the VAXCRTL (at least) keeps track only of subprocesses spawned using fork() and exec(); it will not accumulate the times of subprocesses spawned via pipes, system(), or backticks. So if your numbers look empty, that's why. Not a bug, just VMS being VMS πŸ’€

"unlink" will delete the highest version of a file only. To delete all versions, you need to say:

1 while unlink LIST;

You may need to make this change to scripts written for a Unix system which expect that after a call to "unlink", no files with the names passed to "unlink" will exist. Those scripts are living in a fantasy, respectfully 😭

Note: This can be changed at compile time; if you "use Config" and $Config{'d_unlink_all_versions'} is "define", then "unlink" will delete all versions of a file on the first call. πŸ‘‘

"unlink" will delete a file if at all possible, even if it requires changing file protection (though it won't try to change the protection of the parent directory β€” she has boundaries). You can tell whether you've got explicit delete access to a file by using the "VMS::Filespec::candelete" operator. For instance, in order to delete only files to which you have delete access, you could say something like:

sub safe_unlink {
    my($file,$num);
    foreach $file (@_) {
        next unless VMS::Filespec::candelete($file);
        $num += unlink $file;
    }
    $num;
}

(or you could just use "VMS::Stdio::remove", if you've installed the VMS::Stdio extension distributed with Perl β€” dealer's choice, both cute πŸŽ€)

If "unlink" has to change the file protection to delete the file, and you interrupt it in midstream, the file may be left intact, but with a changed ACL allowing you delete access. So like, heads up on that one 🫢

And just so we're clear: this behavior of "unlink" is to be compatible with POSIX behavior and not traditional VMS behavior. She chose POSIX, she's not sorry πŸ’…

🧚 utime LIST

This operator changes only the modification time of the file (VMS revision date) on ODS-2 volumes and ODS-5 volumes without access dates enabled. On ODS-5 volumes with access dates enabled, the true access time is modified. That's the whole thing. Volume-dependent, iykyk ✨

πŸ’– waitpid PID,FLAGS

If PID is a subprocess started by a piped open() (see open), "waitpid" will wait for that subprocess, and return its final status value in $?. Clean, straightforward, we love her.

If PID is a subprocess created in some other way (e.g. SPAWNed before Perl was invoked), "waitpid" will simply check once per second whether the process has completed, and return when it has. Once per second. She's patient, she's just vibing πŸ¦‹

(If PID specifies a process that isn't a subprocess of the current process, and you invoked Perl with the "-w" switch, a warning will be issued.) You've been warned, bestie 😭
  • Returns PID on success, -1 on error. The FLAGS argument is ignored in all cases. Like, it literally does not care bestie πŸ’€

🌸 Perl variables 🌸

okay so all of this VMS-specific tea applies to the "special" Perl variables listed below, on top of the general lore in perlvar. And if the two ever beef? this one wins. Periodt.

%ENV 🫧

The way %ENV behaves totally depends on how the logical name PERL_ENV_TABLES is translated. If it's defined, it should be a search list, and every element in it points at a place where %ENV elements can live. So if you make Perl read or set $ENV{"name"}, here's how Perl works through the translations of PERL_ENV_TABLES, in order:

CRTL_ENV

This string tells Perl to hit up the CRTL's own internal environ array of key-value pairs, using name as the key. Usually there's barely anything in there, like a few keys max. BUT β€” if Perl got invoked through the C exec[lv]e() function (which happens with some embedded Perl apps, or when you're running under a shell like GNV bash), then the calling program may have already stuffed the environ array full. ✨

CLISYM_[LOCAL]

A string starting with CLISYM_ tells Perl to go look in the CLI's symbol tables, using name as the name of the symbol. When it's reading an element of %ENV, it scans the local symbol table first, then the global one. (yes the original has a lil double-period typo there, we love her for it)

The characters after CLISYM_ are the ones that matter when you set or delete an element of %ENV: if the whole string is exactly CLISYM_LOCAL, the change lands in the local symbol table. Any other ending? Global symbol table gets changed. Choose wisely πŸ’…

Any other string

If an element of PERL_ENV_TABLES translates to literally any other string, that string gets treated as the name of a logical name table, which is then consulted using name as the logical name. The normal search order of access modes applies, as it always does.


πŸ’– ok important: PERL_ENV_TABLES is translated once, right when Perl starts up. Any changes you make while Perl's running? They do not affect %ENV. No take-backs.

If PERL_ENV_TABLES isn't defined, Perl defaults to consulting the logical name tables specified by LNM$FILE_DEV first, and then the CRTL environ array. But! That default order flips when the logical name GNV$UNIX_SHELL is defined β€” like when you're running under GNV bash.

For %ENV operations based on logical names or DCL symbols, the key string gets treated as if it were entirely uppercase, no matter what case you actually typed in your Perl expression. But entries in %ENV based on the CRTL's environ array preserve the case of the key string when stored, and lookups there are case sensitive. iykyk 🌈


When you read an element of %ENV, the locations that PERL_ENV_TABLES points to get checked in order, and the value from the first successful lookup is what you get back.

If the name of the %ENV element contains a semi-colon, it and everything after it get removed. Those bits are ignored when the CRTL environ array or a CLI symbol table is being consulted. BUT if the name is looked up in a logical name table, then that suffix after the semi-colon is treated as the translation index for the lookup. That's how you can pull successive values out of search list logical names, bestie πŸ¦‹

Like, if you say:

$  Define STORY  once,upon,a,time,there,was
$  perl -e "for ($i = 0; $i <= 6; $i++) " -
_$ -e "{ print $ENV{'story;'.$i},' '}"

Perl will print "ONCE UPON A TIME THERE WAS" β€” assuming, obviously, that PERL_ENV_TABLES is set up so the logical name story is found, and not some CLI symbol or CRTL environ element with the same name. 😌


When you set an element of %ENV to a defined string, the corresponding definition gets made in the location that the first translation of PERL_ENV_TABLES points to. If that creates a logical name, it's defined in supervisor mode. (Same deal if an existing logical name was defined in executive or kernel mode β€” an existing user or supervisor mode logical name just gets reset to the new value. No drama.)

If the value is an empty string, the logical name's translation gets defined as a single "NUL" (ASCII "\0") character, because a logical name cannot translate to a zero-length string. That restriction does not apply to CLI symbols or CRTL environ values though β€” those just get set to the empty string. πŸ“


When you set an element of %ENV to undef, the element gets looked up as if you were reading it, and if it's found, it gets deleted. (An item "deleted" from the CRTL environ array is set to the empty string.) Using delete on a %ENV element has a similar effect, BUT after the element is deleted, another lookup attempt happens β€” so an inner-mode logical name, or a name in some other location, can replace the logical name you just deleted. πŸ™ˆ

In either case, only the first value found while searching PERL_ENV_TABLES gets altered.

⚠️ and ngl: it is not possible at present to define a search list logical name via %ENV. Sorry bestie.

$ENV{DEFAULT} is special: when read, it returns Perl's current default device and directory. When set, it resets them. This happens regardless of how PERL_ENV_TABLES is defined. It cannot be cleared or deleted β€” attempts to do so are just silently ignored. πŸ’…


ok so quick note: if you want to pass along any elements of the C-local environ array to a subprocess that isn't started by fork/exec, or isn't running a C program, you can "promote" them to logical names in the current process β€” which then get inherited by all subprocesses. Like this:

foreach my $key (qw[C-local keys you want promoted]) {
    my $temp = $ENV{$key}; # read from C-local array
    $ENV{$key} = $temp;    # and define as logical name
}

(And no, you can't just do "$ENV{$key} = $ENV{$key}" β€” the Perl optimizer is way too smart for that and will just elide the whole expression. 😭)


🚨 DO NOT try to clear %ENV by saying "%ENV = ();" β€” it will throw a fatal error. That's literally equivalent to doing this from DCL:
DELETE/LOGICAL *

You can imagine how bad things would get if, say, the SYS$MANAGER or SYS$SYSTEM logical names got deleted. Bestie. No. 🫠 Put the keyboard down.


So right now, the first time you iterate over %ENV using keys or values, you'll pay a time penalty, because every logical name gets read so %ENV can be fully populated. Subsequent iterations won't reread logical names, so they won't be as slow β€” but they also won't pick up any changes to logical name tables caused by other programs. It's giving snapshot energy πŸ“Έ

And fr fr, you do need to be careful with the logical names representing process-permanent files, like "SYS$INPUT" and "SYS$OUTPUT". The translations for these get a two-byte binary value (0x1B 0x00) prepended, and you have to strip that off if you want to use it. (In previous versions of Perl you couldn't even get the values of these logical names, because the null byte acted as an end-of-string marker.) 🧚

$! πŸ’€

The string value of $! is whatever the CRTL's strerror() function returns, so it'll include the VMS message for VMS-specific errors.

The numeric value of $! is the value of errno β€” except if errno is EVMSERR, in which case $! holds the value of vaxc$errno.

Setting $! always sets errno to the value you specified. And if that value is EVMSERR, it also sets vaxc$errno to 4 (NONAME-F-NOMSG) β€” so the string value of $! won't reflect the VMS error message from before you set $!. Sneaky but true. πŸ‘‘

$^E ✨

This one gives you direct access to the VMS status values in vaxc$errno, which are often way more specific than the generic Unix-style error messages hanging out in $!. Its numeric value is the value of vaxc$errno, and its string value is the corresponding VMS message string, as retrieved by sys$getmsg(). Setting $^E sets vaxc$errno to whatever value you gave it.

Now, Perl does try to keep vaxc$errno current β€” but heads up, if errno isn't EVMSERR, it might not be from the current operation. 🌸

$? πŸ¦‹

The "status value" returned in $? gets synthesized from the subprocess's actual exit status in a way that approximates POSIX wait(5) semantics β€” all so your Perl programs can portably test whether subprocesses finished successfully. 🫢

The low order 8 bits of $? are always 0 under VMS, since the termination status of a process may or may not have been generated by an exception.

The next 8 bits contain the termination status of the program.

If the child process follows the convention of C programs compiled with the _POSIX_EXIT macro set, the status value will contain the actual value of 0 to 255 returned by that program on a normal exit.

With the _POSIX_EXIT macro set, the Unix exit value of zero is represented as a VMS native status of 1. And the Unix values from 2 to 255 are encoded by this equation:

VMS_status = 0x35a000 + (unix_value * 8) + 1.

And in the special case of Unix value 1, the encoding is:

VMS_status = 0x35a000 + 8 + 2 + 0x10000000.

For other termination statuses, the severity portion of the subprocess's exit status gets used: if the severity was success or informational, these bits are all 0; if the severity was warning, they contain a value of 1; if the severity was error or fatal error, they contain the actual severity bits β€” which shakes out to a value of 2 for error and 4 for severe_error. Fatal is just another term for the severe_error status. 😌

So as a result, $? will always be zero if the subprocess's exit status indicated successful completion, and non-zero if a warning or error occurred, or if a program compliant with encoding _POSIX_EXIT values was run and set a status.

ok so how do you tell the difference between a non-zero status that's the result of a VMS native error status and an encoded Unix status? 🧐

You literally can't β€” unless you look at the ${^CHILD_ERROR_NATIVE} value. The ${^CHILD_ERROR_NATIVE} value returns the actual VMS status value, and you check the severity bits.

If the severity bits equal 1, then: if the numeric value for $? is between 2 and 255 or 0, then $? accurately reflects a value passed back from a Unix application. And if $? is 1, and the severity bits indicate a VMS error (2), then $? is from a Unix application exit value.

In practice, Perl scripts that call programs returning _POSIX_EXIT type status values will be expecting those values, and programs that call traditional VMS programs will either be expecting the previous behavior or just checking for a non-zero status. πŸ’–

πŸ’€ and success is always the value 0 in all behaviors. every. single. one. periodt.

Okay now the fun part: when the actual VMS termination status of the child is an error, the $! value gets set internally to the closest Unix errno value to that error. Why tho? So that Perl scripts that test for error messages see the expected Unix-style error message instead of a VMS one. bestie, the vibes stay Unixy on purpose 🫢

And conversely (iconic word), when you set $? in an END block, Perl makes an attempt to convert that POSIX value into a native status that's intelligible to the operating system when Perl exits. What this all boils down to:

  • Set $? to 0 β†’ you get the generic success value SS$_NORMAL ✨
  • Set $? to a non-zero value β†’ you get the generic failure status SS$_ABORT 😭

Also go read exit in perlport, iykyk.

But wait β€” if the PERL_VMS_POSIX_EXIT logical name is defined as ENABLE, setting $? will cause the new value to be encoded into $^E, so that either the original parent or child exit status values 0 to 255 can be automatically recovered by C programs expecting _POSIX_EXIT behavior. Details bestie:

  • If both a parent and a child exit value are non-zero, then it will be assumed that this is actually a VMS native status value to be passed through.
  • The special value of 0xFFFF is almost a NOOP β€” it will cause the current native VMS status in the C library to become the current native Perl VMS status, and it's handled this way as it is known to not be a valid native VMS status value.
  • πŸ‘‘ strongly recommended: only use values in the range of normal Unix parent or child status numbers, 0 to 255. just do that.

The pragma use vmsish 'status' makes $? reflect the actual VMS exit status instead of the default emulation of POSIX status described above. This pragma also disables the conversion of non-zero values to SS$_ABORT when you set $? in an END block β€” but zero will still be converted to SS$_NORMAL. so zero stays cute πŸ’…

🚨 real talk: do not use the pragma use vmsish 'status' with PERL_VMS_POSIX_EXIT enabled. they are at times requesting conflicting actions, and the consequence of ignoring this advice will be undefined, to allow future improvements in the POSIX exit handling. don't test fate bestie.

In general, with PERL_VMS_POSIX_EXIT enabled, more detailed information will be available in the exit status for DCL scripts or other native VMS tools, and it will give the expected information for Posix programs. It has not been made the default in order to preserve backward compatibility. rude but respectful πŸ™ˆ

N.B. Setting DECC$FILENAME_UNIX_REPORT implicitly enables PERL_VMS_POSIX_EXIT. no cap. it just does that.

🌈 Standard modules with VMS-specific differences 🌈

πŸŽ€ SDBM_File πŸŽ€

SDBM_File works properly on VMS. it's giving functioning module, we love to see it 🫢 It has, however, one minor difference:

  • The database directory file created has a .sdbm_dir extension rather than a .dir extension.

Why? Because .dir files are VMS filesystem directory files, and using them for other purposes could cause unacceptable problems. so like, don't. πŸ’€


⭐ Revision date ⭐

Please see the git repository for revision history. very mysterious of them, honestly 🧚


πŸ‘‘ AUTHOR πŸ‘‘

  • Charles Bailey β€” bailey@cor.newman.upenn.edu
  • Craig Berry β€” craigberry@mac.com
  • Dan Sugalski β€” dan@sidhe.org
  • John Malmberg β€” wb8tyw@qsl.net

and that's the whole page bestie!! πŸŽ‰ this was perl v5.44.0, dated 2026-10-17, and you just read PERLVMS(1perl). slay, you're officially a VMS-Perl girlie now πŸ’–πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms