This FAQ answers some of the commonly asked questions (or the ones I can remember, at least) about Perl on VMS systems. It deals with VMS specific issues--for general Perl questions, refer to the PerlFAQ .PODs provided with the Perl5.004 (and later) distribution
perl "-Mblib", perl ACCVIOs and
dies! Why?
$?) from
system or backtick calls. It's really, really strange. What's
going on?
$?'s not just strange, it's downright wrong.
Is there something going on?
Q.Can I use Unix-style file names in my perl programs?
A.Yup, you bet.
Q.Okay, how?
A.Well, there are two different ways. Absolute paths start with a slash, and go /DISK/DIR/DIR/DIR/FILE. They can also go /rooted_logical/dir/dir/file. Relative paths don't start with a slash, and go DIR/DIR/FILE.
Q.Can I use VMS style file names?
A.Sure, go right ahead.
Q.Perl's complaining about files with names like DKA300:[foo]/bar/xyzzy. What's going on?
A.You're mixing your metaphors. Either use Unix style (/dev/dir/dir/file) or VMS style (dev:[dir.dir]file), but don't mix them.
Q.I've got pieces of filenames in both formats and I need to mash them together. What can I do?
A.There are two functions, unixify() and vmsify() that you probably want to know about. unixify() takes a vms style filename and turns it into a unix style one. vmsify() does the opposite. To get them, add a
use VMS::Filespec;
to the top of your perl file.
A.Sometimes, when things do a die() several levels deep, VMS Perl dies a little too hard. If you can, don't do that. If you can't, throwing an eval{} around the statement that dies really badly (like doing a $dbh->disconnect with the DBI module when you have unfinished cursors)
Q.I want Perl to be a command, not a symbol. How?
A.Courtesy of Brad Hughes:
Put the following, modified to reflect where your .exe is, in PERL.CLD:
define verb perl
image perl_root:[exe]perl.exe
cliflags (foreign)
and then
$ set command perl /table=sys$common:[syslib]dcltables.exe -
/output=sys$common:[syslib]dcltables.exe
$ install replace sys$common:[syslib]dcltables.exe
and you don't need perl :== $perl_root:[exe]perl.exe. There's many ways to do it...
A.There's a problem with many versions of CGI.PM on VMS. At line 105, you'll see this:
$CRLF = "\015\012";
You want to change it to
$CRLF = "\n";
This is fixed in later versions of CGI.PM.
A. Nope. The backport library doesn't mix at all well with shared images that share resources (open files and such). That pretty much describes Perl, unfortunately--the whole darned thing is a shared image, as are any .XS modules. If you try, Bad Things Happen.
We're trying to lift this restriction. If you can help out, it'd be great.
Q. What's with all these "Ignored xxx: unreadable" messages I get from Perldoc?
A. A bug for non-unix
platforms sneaked into 5.004_04. This patch to perldoc.pl (which
should also be applied to perldoc.com) will fix the problem.
For those of you who don't read context diffs, it changes the unless
-r on line 156 to if -f)
*** perldoc.pl~ Thu Oct 16 21:12:16 1997
--- perldoc.pl Fri Oct 17 01:08:50 1997
*************** *** 154,158 **** if ($Is_VMS or $Is_MSWin32 or $Is_Dos or $^O eq 'os2') { return $file if -f $file and -r _; ! warn "Ignored $file: unreadable\n" unless -r _; return ''; } --- 154,158 ---- if ($Is_VMS or $Is_MSWin32 or $Is_Dos or $^O eq 'os2') { return $file if -f $file and -r _; ! warn "Ignored $file: unreadable\n" if -f _; return ''; }
Q.
If I try to do a perl "-Mblib", perl ACCVIOs and
dies! Why?
A. There's a whoops in Perl5.004 through _04 at least. This patch by Charles Bailey fixes it. (Note that the fix is off the 5.004_55 development release, so line numbers might be a bit different for you)
--- lib/blib.pm Tue Nov 25 14:52:46 1997
+++ lib/blib.pm Fri Dec 5 19:51:50 1997
@@ -45,6 +45,7 @@
{
my $package = shift;
my $dir = getcwd;
+ if ($^O eq 'VMS') { ($dir = VMS::Filespec::unixify($dir)) =~ s-/$--; }
if (@_)
{
$dir = shift;
--- vms/vms.c Tue Dec 2 00:11:02 1997
+++ vms/vms.c Fri Dec 5 19:49:47 1997
@@ -1019,6 +1019,14 @@
if (*(cp1+2) == '.') cp1++;
if (*(cp1+2) == '/' || *(cp1+2) == '\0') {
if (do_tovmsspec(dir,vmsdir,0) == NULL) return NULL;
+ if (strchr(vmsdir,'/') != NULL) {
+ /* If do_tovmsspec() returned it, it must have VMS syntax
+ * delimiters in it, so it's a mixed VMS/Unix spec. We took
+ * the time to check this here only so we avoid a recursion
+ * loop; otherwise, gigo.
+ */
+ set_errno(EINVAL); set_vaxc_errno(RMS$_SYN); return NULL;
+ }
if (do_fileify_dirspec(vmsdir,trndir,0) == NULL) return NULL;
return do_tounixspec(trndir,buf,ts);
}
A. By default, Perl 5.004 returns perl style status codes. The 'real' status is in the top 24 bits, while the signal the call exited with is in the low byte. This is pretty useless for VMS, but we do it to be compatible across platforms.
To get the VMS return code, you need a use vmsish 'status';
in your script somewhere. This turns on VMS-style return codes.
Q.
$?'s not just strange, it's downright
wrong. Is there something going on?
A. Could be. There's
a bug in some versions of Perl 5.004 (through _04) that bites here. Simple
assignment of $?, like, say, $foo = $?;, doesn't
trigger its magic, and gets you the wrong value. Any other use does, so for
a workaround, do this instead:$foo = "$?";
A. Like this:
open(OUT,"|\@sys\$input"); # mind the backslash in sys$input print OUT "show default\n"; # or any other command print OUT "dir/date"; # or any other command close(OUT);
This courtesy of David Lyon.
A. While we can't help you with the second part, subscribing to the VMS Perl mailing list's pretty easy. Send mail to majordomo@perl.org with the words subscribe VMSPERL in the body of the message. You'll get a message with instructions on what you need to do to confirm your subscription.
And, if you want to really access the wisdom of the ages, see the VMS Perl mailing list archives. This is a great resource. If your question about VMS Perl isn't in these archives, then you should probably ask on this list that you should have just subscribed to.
Last Update: 01-June-2001
Questions or comments?
Write the Webmaster