5 vmsish - Perl pragma to control VMS-specific language features
11 use vmsish 'status'; # or '$?'
17 vmsish::hushed($hush);
24 If no import list is supplied, all possible VMS-specific features are
25 assumed. Currently, there are four VMS-specific features available:
26 'status' (a.k.a '$?'), 'exit', 'time' and 'hushed'.
28 If you're not running VMS, this module does nothing.
32 =item C<vmsish status>
34 This makes C<$?> and C<system> return the native VMS exit status
35 instead of emulating the POSIX exit status.
39 This makes C<exit 1> produce a successful exit (with status SS$_NORMAL),
40 instead of emulating UNIX exit(), which considers C<exit 1> to indicate
41 an error. As with the CRTL's exit() function, C<exit 0> is also mapped
42 to an exit status of SS$_NORMAL, and any other argument to exit() is
43 used directly as Perl's exit status.
47 This makes all times relative to the local time zone, instead of the
48 default of Universal Time (a.k.a Greenwich Mean Time, or GMT).
50 =item C<vmsish hushed>
52 This suppresses printing of VMS status messages to SYS$OUTPUT and
53 SYS$ERROR if Perl terminates with an error status. and allows
54 programs that are expecting "unix-style" Perl to avoid having to parse
55 VMS error messages. It does not supress any messages from Perl
56 itself, just the messages generated by DCL after Perl exits. The DCL
57 symbol $STATUS will still have the termination status, but with a
61 $ perl -e"exit 44;" Non-hushed error exit
62 %SYSTEM-F-ABORT, abort DCL message
64 $STATUS == "%X0000002C"
66 $ perl -e"use vmsish qw(hushed); exit 44;" Hushed error exit
68 $STATUS == "%X1000002C"
70 The 'hushed' flag has a global scope during compilation: the exit() or
71 die() commands that are compiled after 'vmsish hushed' will be hushed
72 when they are executed. Doing a "no vmsish 'hushed'" turns off the
75 The status of the hushed flag also affects output of VMS error
76 messages from compilation errors. Again, you still get the Perl
77 error message (and the code in $STATUS)
80 use vmsish 'hushed'; # turn on hushed flag
81 use Carp; # Carp compiled hushed
82 exit 44; # will be hushed
83 croak('I die'); # will be hushed
84 no vmsish 'hushed'; # turn off hushed flag
85 exit 44; # will not be hushed
86 croak('I die2'): # WILL be hushed, croak was compiled hushed
88 You can also control the 'hushed' flag at run-time, using the built-in
89 routine vmsish::hushed(). Without argument, it returns the hushed status.
90 Since vmsish::hushed is built-in, you do not need to "use vmsish" to call
97 print "Sssshhhh...I'm hushed...\n" if vmsish::hushed();
100 Note that an exit() or die() that is compiled 'hushed' because of "use
101 vmsish" is not un-hushed by calling vmsish::hushed(0) at runtime.
103 The messages from error exits from inside the Perl core are generally
104 more serious, and are not supressed.
108 See L<perlmod/Pragmatic Modules>.
112 my $IsVMS = $^O eq 'VMS';
117 foreach $sememe (@_) {
118 $bits |= 0x40000000, next if $sememe eq 'status' || $sememe eq '$?';
119 $bits |= 0x80000000, next if $sememe eq 'time';
125 return unless $IsVMS;
128 $^H |= bits(@_ ? @_ : qw(status time));
131 foreach $sememe (@_ ? @_ : qw(exit hushed)) {
132 $^H{'vmsish_exit'} = 1 if $sememe eq 'exit';
133 vmsish::hushed(1) if $sememe eq 'hushed';
138 return unless $IsVMS;
141 $^H &= ~ bits(@_ ? @_ : qw(status time));
144 foreach $sememe (@_ ? @_ : qw(exit hushed)) {
145 $^H{'vmsish_exit'} = 0 if $sememe eq 'exit';
146 vmsish::hushed(0) if $sememe eq 'hushed';