source: trunk/third/perl/vms/ext/vmsish.pm @ 14545

Revision 14545, 2.3 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r14544, which included commits to RCS files with non-trunk default branches.
Line 
1package vmsish;
2
3=head1 NAME
4
5vmsish - Perl pragma to control VMS-specific language features
6
7=head1 SYNOPSIS
8
9    use vmsish;
10
11    use vmsish 'status';        # or '$?'
12    use vmsish 'exit';
13    use vmsish 'time';
14    use vmsish 'hushed';
15
16    use vmsish;
17    no vmsish 'time';
18
19=head1 DESCRIPTION
20
21If no import list is supplied, all possible VMS-specific features are
22assumed.  Currently, there are four VMS-specific features available:
23'status' (a.k.a '$?'), 'exit', 'time' and 'hushed'.
24
25=over 6
26
27=item C<vmsish status>
28
29This makes C<$?> and C<system> return the native VMS exit status
30instead of emulating the POSIX exit status.
31
32=item C<vmsish exit>
33
34This makes C<exit 1> produce a successful exit (with status SS$_NORMAL),
35instead of emulating UNIX exit(), which considers C<exit 1> to indicate
36an error.  As with the CRTL's exit() function, C<exit 0> is also mapped
37to an exit status of SS$_NORMAL, and any other argument to exit() is
38used directly as Perl's exit status.
39
40=item C<vmsish time>
41
42This makes all times relative to the local time zone, instead of the
43default of Universal Time (a.k.a Greenwich Mean Time, or GMT).
44
45=item C<vmsish hushed>
46
47This supresses printing of VMS status messages to SYS$OUTPUT and SYS$ERROR
48if Perl terminates with an error status.  This primarily effects error
49exits from things like compiler errors or "standard Perl" runtime errors,
50where text error messages are also generated by Perl.
51
52The error exits from inside VMS.C are generally more serious, and are
53not supressed.
54
55=back
56
57See L<perlmod/Pragmatic Modules>.
58
59=cut
60
61if ($^O ne 'VMS') {
62    require Carp;
63    Carp::croak("This isn't VMS");
64}
65
66sub bits {
67    my $bits = 0;
68    my $sememe;
69    foreach $sememe (@_) {
70        $bits |= 0x20000000, next if $sememe eq 'hushed';
71        $bits |= 0x40000000, next if $sememe eq 'status' || $sememe eq '$?';
72        $bits |= 0x80000000, next if $sememe eq 'time';
73    }
74    $bits;
75}
76
77sub import {
78    shift;
79    $^H |= bits(@_ ? @_ : qw(status time hushed));
80    my $sememe;
81
82    foreach $sememe (@_ ? @_ : qw(exit)) {
83        $^H{'vmsish_exit'}   = 1 if $sememe eq 'exit';
84    }
85}
86
87sub unimport {
88    shift;
89    $^H &= ~ bits(@_ ? @_ : qw(status time hushed));
90    my $sememe;
91
92    foreach $sememe (@_ ? @_ : qw(exit)) {
93        $^H{'vmsish_exit'}   = 0 if $sememe eq 'exit';
94    }
95}
96
971;
Note: See TracBrowser for help on using the repository browser.