This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
remove an obsolete special case for VOS handling of permissions in AnyDBM_File.t
[perl5.git] / lib / English.pm
CommitLineData
8990e307
LW
1package English;
2
20961b64 3our $VERSION = '1.06';
b75c8c73 4
8990e307 5require Exporter;
abc0156b 6@ISA = qw(Exporter);
8990e307 7
f06db76b
AD
8=head1 NAME
9
10English - use nice English (or awk) names for ugly punctuation variables
11
12=head1 SYNOPSIS
13
14 use English;
3b5bc0dd
FC
15 use English qw( -no_match_vars ) ; # Avoids regex performance penalty
16 # in perl 5.16 and earlier
f06db76b
AD
17 ...
18 if ($ERRNO =~ /denied/) { ... }
19
20=head1 DESCRIPTION
21
22This module provides aliases for the built-in variables whose
23names no one seems to like to read. Variables with side-effects
24which get triggered just by accessing them (like $0) will still
25be affected.
26
27For those variables that have an B<awk> version, both long
28and short English alternatives are provided. For example,
29the C<$/> variable can be referred to either $RS or
30$INPUT_RECORD_SEPARATOR if you are using the English module.
31
32See L<perlvar> for a complete list of these.
33
60ed1d8c 34=head1 PERFORMANCE
f2545c07 35
3b5bc0dd
FC
36NOTE: This was fixed in perl 5.18. Mentioning these three variables no
37longer makes a speed difference. This section still applies if your code
38is to run on perl 5.16 or earlier.
39
60ed1d8c
GS
40This module can provoke sizeable inefficiencies for regular expressions,
41due to unfortunate implementation details. If performance matters in
42your application and you don't need $PREMATCH, $MATCH, or $POSTMATCH,
43try doing
44
45 use English qw( -no_match_vars ) ;
46
47. B<It is especially important to do this in modules to avoid penalizing
48all applications which use them.>
f2545c07 49
f06db76b
AD
50=cut
51
db376a24 52no warnings;
748a9306 53
60ed1d8c
GS
54my $globbed_match ;
55
748a9306
LW
56# Grandfather $NAME import
57sub import {
58 my $this = shift;
60ed1d8c 59 my @list = grep { ! /^-no_match_vars$/ } @_ ;
748a9306 60 local $Exporter::ExportLevel = 1;
60ed1d8c
GS
61 if ( @_ == @list ) {
62 *EXPORT = \@COMPLETE_EXPORT ;
63 $globbed_match ||= (
64 eval q{
a33bf49b
RGS
65 *MATCH = *& ;
66 *PREMATCH = *` ;
67 *POSTMATCH = *' ;
60ed1d8c
GS
68 1 ;
69 }
70 || do {
71 require Carp ;
09e96b99 72 Carp::croak("Can't create English for match leftovers: $@") ;
60ed1d8c
GS
73 }
74 ) ;
75 }
76 else {
77 *EXPORT = \@MINIMAL_EXPORT ;
78 }
748a9306
LW
79 Exporter::import($this,grep {s/^\$/*/} @list);
80}
a0d0e21e 81
60ed1d8c 82@MINIMAL_EXPORT = qw(
8990e307 83 *ARG
748a9306
LW
84 *LAST_PAREN_MATCH
85 *INPUT_LINE_NUMBER
86 *NR
87 *INPUT_RECORD_SEPARATOR
88 *RS
89 *OUTPUT_AUTOFLUSH
90 *OUTPUT_FIELD_SEPARATOR
91 *OFS
92 *OUTPUT_RECORD_SEPARATOR
93 *ORS
94 *LIST_SEPARATOR
95 *SUBSCRIPT_SEPARATOR
96 *SUBSEP
97 *FORMAT_PAGE_NUMBER
98 *FORMAT_LINES_PER_PAGE
99 *FORMAT_LINES_LEFT
100 *FORMAT_NAME
101 *FORMAT_TOP_NAME
102 *FORMAT_LINE_BREAK_CHARACTERS
103 *FORMAT_FORMFEED
104 *CHILD_ERROR
105 *OS_ERROR
106 *ERRNO
d57fa8b6 107 *EXTENDED_OS_ERROR
748a9306
LW
108 *EVAL_ERROR
109 *PROCESS_ID
110 *PID
111 *REAL_USER_ID
112 *UID
113 *EFFECTIVE_USER_ID
114 *EUID
115 *REAL_GROUP_ID
116 *GID
117 *EFFECTIVE_GROUP_ID
118 *EGID
119 *PROGRAM_NAME
120 *PERL_VERSION
121 *ACCUMULATOR
108015d7 122 *COMPILING
748a9306
LW
123 *DEBUGGING
124 *SYSTEM_FD_MAX
125 *INPLACE_EDIT
126 *PERLDB
127 *BASETIME
128 *WARNING
129 *EXECUTABLE_NAME
d57fa8b6 130 *OSNAME
66558a10
GS
131 *LAST_REGEXP_CODE_RESULT
132 *EXCEPTIONS_BEING_CAUGHT
77ea4f6d 133 *LAST_SUBMATCH_RESULT
fe307981
GS
134 @LAST_MATCH_START
135 @LAST_MATCH_END
8990e307
LW
136);
137
60ed1d8c
GS
138
139@MATCH_EXPORT = qw(
140 *MATCH
141 *PREMATCH
142 *POSTMATCH
143);
144
145@COMPLETE_EXPORT = ( @MINIMAL_EXPORT, @MATCH_EXPORT ) ;
146
1ef8987b 147# The ground of all being.
8990e307 148
8990e307
LW
149 *ARG = *_ ;
150
151# Matching.
152
a33bf49b
RGS
153 *LAST_PAREN_MATCH = *+ ;
154 *LAST_SUBMATCH_RESULT = *^N ;
155 *LAST_MATCH_START = *-{ARRAY} ;
156 *LAST_MATCH_END = *+{ARRAY} ;
8990e307
LW
157
158# Input.
159
a33bf49b
RGS
160 *INPUT_LINE_NUMBER = *. ;
161 *NR = *. ;
162 *INPUT_RECORD_SEPARATOR = */ ;
163 *RS = */ ;
8990e307
LW
164
165# Output.
166
a33bf49b
RGS
167 *OUTPUT_AUTOFLUSH = *| ;
168 *OUTPUT_FIELD_SEPARATOR = *, ;
169 *OFS = *, ;
170 *OUTPUT_RECORD_SEPARATOR = *\ ;
171 *ORS = *\ ;
8990e307
LW
172
173# Interpolation "constants".
174
a33bf49b
RGS
175 *LIST_SEPARATOR = *" ;
176 *SUBSCRIPT_SEPARATOR = *; ;
177 *SUBSEP = *; ;
8990e307
LW
178
179# Formats
180
a33bf49b
RGS
181 *FORMAT_PAGE_NUMBER = *% ;
182 *FORMAT_LINES_PER_PAGE = *= ;
183 *FORMAT_LINES_LEFT = *- ;
184 *FORMAT_NAME = *~ ;
185 *FORMAT_TOP_NAME = *^ ;
186 *FORMAT_LINE_BREAK_CHARACTERS = *: ;
187 *FORMAT_FORMFEED = *^L ;
8990e307
LW
188
189# Error status.
190
a33bf49b
RGS
191 *CHILD_ERROR = *? ;
192 *OS_ERROR = *! ;
193 *ERRNO = *! ;
194 *OS_ERROR = *! ;
195 *ERRNO = *! ;
196 *EXTENDED_OS_ERROR = *^E ;
197 *EVAL_ERROR = *@ ;
8990e307
LW
198
199# Process info.
200
a33bf49b
RGS
201 *PROCESS_ID = *$ ;
202 *PID = *$ ;
203 *REAL_USER_ID = *< ;
204 *UID = *< ;
205 *EFFECTIVE_USER_ID = *> ;
206 *EUID = *> ;
207 *REAL_GROUP_ID = *( ;
208 *GID = *( ;
209 *EFFECTIVE_GROUP_ID = *) ;
210 *EGID = *) ;
211 *PROGRAM_NAME = *0 ;
8990e307
LW
212
213# Internals.
214
a33bf49b
RGS
215 *PERL_VERSION = *^V ;
216 *ACCUMULATOR = *^A ;
217 *COMPILING = *^C ;
218 *DEBUGGING = *^D ;
219 *SYSTEM_FD_MAX = *^F ;
220 *INPLACE_EDIT = *^I ;
221 *PERLDB = *^P ;
222 *LAST_REGEXP_CODE_RESULT = *^R ;
223 *EXCEPTIONS_BEING_CAUGHT = *^S ;
224 *BASETIME = *^T ;
225 *WARNING = *^W ;
226 *EXECUTABLE_NAME = *^X ;
227 *OSNAME = *^O ;
8990e307
LW
228
229# Deprecated.
230
a33bf49b
RGS
231# *ARRAY_BASE = *[ ;
232# *OFMT = *# ;
a33bf49b 233# *OLD_PERL_VERSION = *] ;
8990e307
LW
234
2351;