Operating System - OpenVMS
Showing results for 
Search instead for 
Did you mean: 

Perl - capturing output of DCL lexicals

Go to solution
Jack Trachtman
Super Advisor

Perl - capturing output of DCL lexicals

I haven't been able to find an example of this (or figure it out myself), and really don't won't to install the VMS::system module that someone wrote.

So, how can I capture the output of a DCL lexical from within a Perl script? I've tried various combinations of Perl calls to DCL with various combinations of back-ticks, etc, without any success. Can anyone give me at least one example?

John Gillings
Honored Contributor

Re: Perl - capturing output of DCL lexicals


dumb question... what do you mean by "output of a lexical function"? I'm not aware of any that produce any output. By definition, they return a function result, usually assigned to a symbol.

I'm guessing you want to capture the lexical function result as a string in perl? How about executing

write sys$output f$yourfunction(params...)

this should work inside back ticks.

(sorry, no perl installed here, so no example)
A crucible of informative mistakes
Hein van den Heuvel
Honored Contributor

Re: Perl - capturing output of DCL lexicals

Well, to capture the output from DCL lexical in a perl script you would have to have a sub process executing a dcl stream.

For example:

$ type tmp.pl
use strict;
use warnings;
my $cluster = qx(write sys\$output f\$getdvi("sys\$disk","cluster"));
my $test = 10 * $cluster;
print "$test\n";
$ perl tmp.pl

Notice the ugly \ (backslash) escapes to make the $ signs not be interpreted as perl variables.

For one liners you can use basic DCL substitution magic:

$ perl -e "$test=10*''f$getdvi("sys$disk","cluster")'; print $test"

I appreciate you are probably looking for a generic solution. But for now, what immediate problem are you trying to solve. That may allow us to make concrete examples.

Also, many DCL lexical outputs are avaibale as posix style build-ins. And there are operators for may F$FILE functions like -s for file size in bytes, -M for RDT in days since program start. For F$SEARCH there is 'glob' and so on!

Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting

Craig A Berry
Honored Contributor

Re: Perl - capturing output of DCL lexicals

Hein's advice is sound as usual. Basically you have to keep track of DCL quoting rules and Perl quoting rules at the same time. Or you need to find a Perl operator that gives you the same information.

Or you can set symbols and/or logicals from DCL and retrieve them from Perl.

Or you need to build the VMS::* extensions. Note that VMS::System only has the SYI functions and there are separate extensions that cover QUI, DVI, JPI etc. These are not especially difficult to build and install, so depending on the definition of "don't want to" in your post, that's a hurdle that can be gotten over. Let me know if there is some particular problem you had with them.
Jack Trachtman
Super Advisor

Re: Perl - capturing output of DCL lexicals


Your example is extactly what I was having problems with.


You've hit my problem squarely on the head!


You've given the example and answer I needed: escape those pesky dollar signs! I can get my code to work now.

Thanks all for responding.