On Thu, 26 Apr 2001, Forrest Cahoon wrote:
> Hello, vms-perlers!
>
> I have a need to mix Perl and DCL in interesting ways.
>
> I'm processing commands that are being passed to perl. What these
> commands are supposed to do could most easily be done in DCL ... it's
> a case where running one (written in-house) program will set symbols and
> change the default directory used by the next program.
For symbols from perl:
use VMS::DCLsym;
For changing directories use chdir();. For changing directories in ways
that persist after the perl.exe image exits then:
use VMS::Stdio qw(&setdef);
setdef($directory_specification);
> I've been writing perl hooks into our local C functions here, but I'm
> afraid I'd have to write a gazillion hooks and duplicate a lot of
> functionality to do this all from within perl. It isn't really an
> option.
h2xs is your friend. Run it over your header files. Do so on a Unix box
if it'll help with filename case preservation and such matters.
> The obvious kludge is to get perl to write a temporary DCL command
> file, then execute that file with system(). I'll probably resort to
> that for now, but I'm hoping there's a better way.
You can obtain the $write sys$output output from using backticks
like so:
@output = `\@$dcl_script`;
if ($?) { warn "something went bang"; }
> The ideal, which I guess is probably impossible, is to have some way
> of executing DCL commands in the same process context as the perl
> process itself. That would allow people to mix perl and DCL pretty
> freely ... yeah, it would be great! You could like, _slowly_ migrate
> your legacy DCL files over to perl. OK, I'm dreaming.
>
> What I think would probably be possible (for someone to implement,
> perhaps not myself) is a DCL interpreter object, with a way for perl
> to write into its SYS$INPUT, and read from SYS$OUPUT and SYS$ERROR.
Would a pipe help? Something along the lines of:
open(PIPEHANDLE,"| \@$script");
> From what I've read, $CREPRC seems like it could be used to set up
> such an object. The I/O confuses me, though. This is where mailboxes
> are used, right? I know that if you're not careful, it's very easy to
> get into a deadlock situation, so I'm a little nervous about just
> jumping in and trying to write this myself ...
>
> Has anyone done something like this already? Does it sound
> reasonable? Anyone want to write it for me?
As recent traffic on the vmsperl mailing list indicates I/O through MBX's
is difficult if you are expecting unix byte stream semantics. However, it
does not sound like you are so you would probably do well to make
effective use of what VMS perl already has to offer.
Peter Prymmer