Ed James, TCS Inc, 410-295-1919, wrote:

> Hello,
> 
> I am working on multi-platform Perl scripts for VMS & NT.
> 
> The NT Perl does not have some files, such as vmsish.pl. I have figured out
> that I can create a BEGIN block that checks $^O for VMS and does a
> "require vmsish.pm; vmsish::import( 'vmsish', 'exit', 'status');".
> This way I don't get the "vmsish.pm not found" message from the "use vmsish".
> 
> When I had the "require ..." in the regular main line code, such as:

  my $EXIT_SUCCESS;
  my $EXIT_BADPARAM;
  BEGIN {
     if( $^O eq 'VMS') {
         require vmsish; vmsish::import( 'vmsish', 'exit', 'status');
         $EXIT_SUCCESS = 1;              # ok
         $EXIT_BADPARAM = 20;            # invalid parameter
     }
     else {
         $EXIT_SUCCESS = 0;
         $EXIT_BADPARAM = 1;
     }
  }
  print "\$EXIT_SUCCESS = $EXIT_SUCCESS\n";
  print "\$EXIT_BADPARAM = $EXIT_BADPARAM\n";
  exit($EXIT_SUCCESS);
__END__

  $ perl "-Mstrict" -w test.plx
  $EXIT_SUCCESS = 1
  $EXIT_BADPARAM = 20
  $ sho sym $status
  $STATUS == "%X00000001"

> the vmsish code is evidently brought into the block's name space and does
> not work outside of the block. An "exit($EXIT_SUCCESS)" gives the VMS
> message "%SYSTEM-F-ABORT, abort".
> 
> Is there a way to import a module within a block and have the imported
> entities be in anothe name space, such as the main:: name space?

I used the trick of declaring the variables my() above.

Peter Prymmer

Reply via email to