line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ehp15; |
2
|
389
|
|
|
389
|
|
10831
|
use strict; |
|
389
|
|
|
|
|
2154
|
|
|
389
|
|
|
|
|
14651
|
|
3
|
|
|
|
|
|
|
###################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Ehp15 - Run-time routines for HP15.pm |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# http://search.cpan.org/dist/Char-HP15/ |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019 INABA Hitoshi |
10
|
|
|
|
|
|
|
###################################################################### |
11
|
|
|
|
|
|
|
|
12
|
389
|
|
|
389
|
|
7543
|
use 5.00503; # Galapagos Consensus 1998 for primetools |
|
389
|
|
|
|
|
2647
|
|
13
|
|
|
|
|
|
|
# use 5.008001; # Lancaster Consensus 2013 for toolchains |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# 12.3. Delaying use Until Runtime |
16
|
|
|
|
|
|
|
# in Chapter 12. Packages, Libraries, and Modules |
17
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
18
|
|
|
|
|
|
|
# (and so on) |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Version numbers should be boring |
21
|
|
|
|
|
|
|
# http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/ |
22
|
|
|
|
|
|
|
# For the impatient, the disinterested or those who just want to follow |
23
|
|
|
|
|
|
|
# a recipe, my advice for all modules is this: |
24
|
|
|
|
|
|
|
# our $VERSION = "0.001"; # or "0.001_001" for a dev release |
25
|
|
|
|
|
|
|
# $VERSION = eval $VERSION; # No!! because '1.10' makes '1.1' |
26
|
|
|
|
|
|
|
|
27
|
389
|
|
|
389
|
|
3888
|
use vars qw($VERSION); |
|
389
|
|
|
|
|
769
|
|
|
389
|
|
|
|
|
75221
|
|
28
|
|
|
|
|
|
|
$VERSION = '1.13'; |
29
|
|
|
|
|
|
|
$VERSION = $VERSION; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
BEGIN { |
32
|
389
|
50
|
|
389
|
|
8970
|
if ($^X =~ / jperl /oxmsi) { |
33
|
0
|
|
|
|
|
0
|
die __FILE__, ": needs perl(not jperl) 5.00503 or later. (\$^X==$^X)\n"; |
34
|
|
|
|
|
|
|
} |
35
|
389
|
|
|
|
|
2162
|
if (CORE::ord('A') == 193) { |
36
|
|
|
|
|
|
|
die __FILE__, ": is not US-ASCII script (may be EBCDIC or EBCDIK script).\n"; |
37
|
|
|
|
|
|
|
} |
38
|
389
|
|
|
|
|
54135
|
if (CORE::ord('A') != 0x41) { |
39
|
|
|
|
|
|
|
die __FILE__, ": is not US-ASCII script (must be US-ASCII script).\n"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
BEGIN { |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# instead of utf8.pm |
46
|
389
|
|
|
389
|
|
29951
|
CORE::eval q{ |
|
389
|
|
|
389
|
|
4200
|
|
|
389
|
|
|
128
|
|
3320
|
|
|
389
|
|
|
|
|
49272
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
no warnings qw(redefine); |
48
|
|
|
|
|
|
|
*utf8::upgrade = sub { CORE::length $_[0] }; |
49
|
|
|
|
|
|
|
*utf8::downgrade = sub { 1 }; |
50
|
|
|
|
|
|
|
*utf8::encode = sub { }; |
51
|
|
|
|
|
|
|
*utf8::decode = sub { 1 }; |
52
|
|
|
|
|
|
|
*utf8::is_utf8 = sub { }; |
53
|
|
|
|
|
|
|
*utf8::valid = sub { 1 }; |
54
|
|
|
|
|
|
|
}; |
55
|
389
|
50
|
|
|
|
179638
|
if ($@) { |
56
|
0
|
|
|
|
|
0
|
*utf8::upgrade = sub { CORE::length $_[0] }; |
|
0
|
|
|
|
|
0
|
|
57
|
0
|
|
|
|
|
0
|
*utf8::downgrade = sub { 1 }; |
|
0
|
|
|
|
|
0
|
|
58
|
0
|
|
|
|
|
0
|
*utf8::encode = sub { }; |
59
|
0
|
|
|
|
|
0
|
*utf8::decode = sub { 1 }; |
|
0
|
|
|
|
|
0
|
|
60
|
0
|
|
|
|
|
0
|
*utf8::is_utf8 = sub { }; |
61
|
0
|
|
|
|
|
0
|
*utf8::valid = sub { 1 }; |
|
0
|
|
|
|
|
0
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# instead of Symbol.pm |
66
|
0
|
|
|
|
|
0
|
BEGIN { |
67
|
|
|
|
|
|
|
sub gensym () { |
68
|
0
|
0
|
|
0
|
0
|
0
|
if ($] < 5.006) { |
69
|
0
|
|
|
|
|
0
|
return \do { local *_ }; |
|
0
|
|
|
|
|
0
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
0
|
|
|
|
|
0
|
return undef; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub qualify ($$) { |
77
|
0
|
|
|
1152
|
0
|
0
|
my($name) = @_; |
78
|
|
|
|
|
|
|
|
79
|
1152
|
50
|
|
|
|
2707
|
if (ref $name) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
80
|
1152
|
|
|
|
|
4595
|
return $name; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif (Ehp15::index($name,'::') >= 0) { |
83
|
0
|
|
|
|
|
0
|
return $name; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
elsif (Ehp15::index($name,"'") >= 0) { |
86
|
0
|
|
|
|
|
0
|
return $name; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# special character, "^xyz" |
90
|
|
|
|
|
|
|
elsif ($name =~ /\A \^ [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]+ \z/x) { |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# RGS 2001-11-05 : translate leading ^X to control-char |
93
|
0
|
|
|
|
|
0
|
$name =~ s{\A \^ ([ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_]) }{'qq(\c'.$1.')'}xee; |
|
0
|
|
|
|
|
0
|
|
94
|
0
|
|
|
|
|
0
|
return 'main::' . $name; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Global names |
98
|
|
|
|
|
|
|
elsif ($name =~ /\A (?: ARGV | ARGVOUT | ENV | INC | SIG | STDERR | STDIN | STDOUT ) \z/x) { |
99
|
0
|
|
|
|
|
0
|
return 'main::' . $name; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# or other |
103
|
|
|
|
|
|
|
elsif ($name =~ /\A [^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz] \z/x) { |
104
|
0
|
|
|
|
|
0
|
return 'main::' . $name; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
elsif (defined $_[1]) { |
108
|
0
|
|
|
|
|
0
|
return $_[1] . '::' . $name; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
else { |
111
|
1152
|
|
|
|
|
9733
|
return (caller)[0] . '::' . $name; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub qualify_to_ref ($;$) { |
116
|
0
|
50
|
|
1152
|
0
|
0
|
if (defined $_[1]) { |
117
|
389
|
|
|
389
|
|
6860
|
no strict qw(refs); |
|
389
|
|
|
|
|
2546
|
|
|
389
|
|
|
|
|
42105
|
|
118
|
1152
|
|
|
|
|
3384
|
return \*{ qualify $_[0], $_[1] }; |
|
0
|
|
|
|
|
0
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
else { |
121
|
389
|
|
|
389
|
|
2499
|
no strict qw(refs); |
|
389
|
|
|
0
|
|
2221
|
|
|
389
|
|
|
|
|
99467
|
|
122
|
0
|
|
|
|
|
0
|
return \*{ qualify $_[0], (caller)[0] }; |
|
1152
|
|
|
|
|
1841
|
|
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# P.714 29.2.39. flock |
128
|
|
|
|
|
|
|
# in Chapter 29: Functions |
129
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# P.863 flock |
132
|
|
|
|
|
|
|
# in Chapter 27: Functions |
133
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub LOCK_SH() {1} |
136
|
|
|
|
|
|
|
sub LOCK_EX() {2} |
137
|
|
|
|
|
|
|
sub LOCK_UN() {8} |
138
|
|
|
|
|
|
|
sub LOCK_NB() {4} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# instead of Carp.pm |
141
|
|
|
|
|
|
|
sub carp; |
142
|
|
|
|
|
|
|
sub croak; |
143
|
|
|
|
|
|
|
sub cluck; |
144
|
|
|
|
|
|
|
sub confess; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# 6.18. Matching Multiple-Byte Characters |
147
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
148
|
|
|
|
|
|
|
# of ISBN 978-1-56592-243-3 Perl Perl Cookbook. |
149
|
|
|
|
|
|
|
# (and so on) |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# regexp of character |
152
|
|
|
|
|
|
|
my $your_char = q{[\x80-\xA0\xE0-\xFE][\x00-\xFF]|[\x00-\xFF]}; |
153
|
389
|
|
|
389
|
|
5541
|
use vars qw($qq_char); $qq_char = qr/\\c[\x40-\x5F]|\\?(?:$your_char)/oxms; |
|
389
|
|
|
|
|
2334
|
|
|
389
|
|
|
|
|
26919
|
|
154
|
389
|
|
|
389
|
|
2543
|
use vars qw($q_char); $q_char = qr/$your_char/oxms; |
|
389
|
|
|
|
|
690
|
|
|
389
|
|
|
|
|
728355
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# |
157
|
|
|
|
|
|
|
# HP-15 character range per length |
158
|
|
|
|
|
|
|
# |
159
|
|
|
|
|
|
|
my %range_tr = (); |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# |
162
|
|
|
|
|
|
|
# HP-15 case conversion |
163
|
|
|
|
|
|
|
# |
164
|
|
|
|
|
|
|
my %lc = (); |
165
|
|
|
|
|
|
|
@lc{qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)} = |
166
|
|
|
|
|
|
|
qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); |
167
|
|
|
|
|
|
|
my %uc = (); |
168
|
|
|
|
|
|
|
@uc{qw(a b c d e f g h i j k l m n o p q r s t u v w x y z)} = |
169
|
|
|
|
|
|
|
qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z); |
170
|
|
|
|
|
|
|
my %fc = (); |
171
|
|
|
|
|
|
|
@fc{qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)} = |
172
|
|
|
|
|
|
|
qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
if (0) { |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
elsif (__PACKAGE__ =~ / \b Ehp15 \z/oxms) { |
178
|
|
|
|
|
|
|
%range_tr = ( |
179
|
|
|
|
|
|
|
1 => [ [0x00..0x7F], |
180
|
|
|
|
|
|
|
[0xA1..0xDF], |
181
|
|
|
|
|
|
|
[0xFF..0xFF], |
182
|
|
|
|
|
|
|
], |
183
|
|
|
|
|
|
|
2 => [ [0x80..0xA0],[0x21..0x7E], |
184
|
|
|
|
|
|
|
[0x80..0xA0],[0x80..0xFF], |
185
|
|
|
|
|
|
|
[0xE0..0xFE],[0x21..0x7E], |
186
|
|
|
|
|
|
|
[0xE0..0xFE],[0x80..0xFF], |
187
|
|
|
|
|
|
|
], |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
else { |
192
|
|
|
|
|
|
|
croak "Don't know my package name '@{[__PACKAGE__]}'"; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# |
196
|
|
|
|
|
|
|
# @ARGV wildcard globbing |
197
|
|
|
|
|
|
|
# |
198
|
|
|
|
|
|
|
sub import { |
199
|
|
|
|
|
|
|
|
200
|
1152
|
50
|
|
5
|
|
6251
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
201
|
5
|
|
|
|
|
84
|
my @argv = (); |
202
|
0
|
|
|
|
|
0
|
for (@ARGV) { |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# has space |
205
|
0
|
0
|
|
|
|
0
|
if (/\A (?:$q_char)*? [ ] /oxms) { |
|
|
0
|
|
|
|
|
|
206
|
0
|
0
|
|
|
|
0
|
if (my @glob = Ehp15::glob(qq{"$_"})) { |
207
|
0
|
|
|
|
|
0
|
push @argv, @glob; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
else { |
210
|
0
|
|
|
|
|
0
|
push @argv, $_; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# has wildcard metachar |
215
|
|
|
|
|
|
|
elsif (/\A (?:$q_char)*? [*?] /oxms) { |
216
|
0
|
0
|
|
|
|
0
|
if (my @glob = Ehp15::glob($_)) { |
217
|
0
|
|
|
|
|
0
|
push @argv, @glob; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
else { |
220
|
0
|
|
|
|
|
0
|
push @argv, $_; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# no wildcard globbing |
225
|
|
|
|
|
|
|
else { |
226
|
0
|
|
|
|
|
0
|
push @argv, $_; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
} |
229
|
0
|
|
|
|
|
0
|
@ARGV = @argv; |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
0
|
*Char::ord = \&HP15::ord; |
233
|
5
|
|
|
|
|
24
|
*Char::ord_ = \&HP15::ord_; |
234
|
5
|
|
|
|
|
13
|
*Char::reverse = \&HP15::reverse; |
235
|
5
|
|
|
|
|
12
|
*Char::getc = \&HP15::getc; |
236
|
5
|
|
|
|
|
12
|
*Char::length = \&HP15::length; |
237
|
5
|
|
|
|
|
12
|
*Char::substr = \&HP15::substr; |
238
|
5
|
|
|
|
|
9
|
*Char::index = \&HP15::index; |
239
|
5
|
|
|
|
|
11
|
*Char::rindex = \&HP15::rindex; |
240
|
5
|
|
|
|
|
10
|
*Char::eval = \&HP15::eval; |
241
|
5
|
|
|
|
|
29
|
*Char::escape = \&HP15::escape; |
242
|
5
|
|
|
|
|
14
|
*Char::escape_token = \&HP15::escape_token; |
243
|
5
|
|
|
|
|
61
|
*Char::escape_script = \&HP15::escape_script; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# P.230 Care with Prototypes |
247
|
|
|
|
|
|
|
# in Chapter 6: Subroutines |
248
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
249
|
|
|
|
|
|
|
# |
250
|
|
|
|
|
|
|
# If you aren't careful, you can get yourself into trouble with prototypes. |
251
|
|
|
|
|
|
|
# But if you are careful, you can do a lot of neat things with them. This is |
252
|
|
|
|
|
|
|
# all very powerful, of course, and should only be used in moderation to make |
253
|
|
|
|
|
|
|
# the world a better place. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# P.332 Care with Prototypes |
256
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
257
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
258
|
|
|
|
|
|
|
# |
259
|
|
|
|
|
|
|
# If you aren't careful, you can get yourself into trouble with prototypes. |
260
|
|
|
|
|
|
|
# But if you are careful, you can do a lot of neat things with them. This is |
261
|
|
|
|
|
|
|
# all very powerful, of course, and should only be used in moderation to make |
262
|
|
|
|
|
|
|
# the world a better place. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# |
265
|
|
|
|
|
|
|
# Prototypes of subroutines |
266
|
|
|
|
|
|
|
# |
267
|
|
|
|
0
|
|
|
sub unimport {} |
268
|
|
|
|
|
|
|
sub Ehp15::split(;$$$); |
269
|
|
|
|
|
|
|
sub Ehp15::tr($$$$;$); |
270
|
|
|
|
|
|
|
sub Ehp15::chop(@); |
271
|
|
|
|
|
|
|
sub Ehp15::index($$;$); |
272
|
|
|
|
|
|
|
sub Ehp15::rindex($$;$); |
273
|
|
|
|
|
|
|
sub Ehp15::lcfirst(@); |
274
|
|
|
|
|
|
|
sub Ehp15::lcfirst_(); |
275
|
|
|
|
|
|
|
sub Ehp15::lc(@); |
276
|
|
|
|
|
|
|
sub Ehp15::lc_(); |
277
|
|
|
|
|
|
|
sub Ehp15::ucfirst(@); |
278
|
|
|
|
|
|
|
sub Ehp15::ucfirst_(); |
279
|
|
|
|
|
|
|
sub Ehp15::uc(@); |
280
|
|
|
|
|
|
|
sub Ehp15::uc_(); |
281
|
|
|
|
|
|
|
sub Ehp15::fc(@); |
282
|
|
|
|
|
|
|
sub Ehp15::fc_(); |
283
|
|
|
|
|
|
|
sub Ehp15::ignorecase; |
284
|
|
|
|
|
|
|
sub Ehp15::classic_character_class; |
285
|
|
|
|
|
|
|
sub Ehp15::capture; |
286
|
|
|
|
|
|
|
sub Ehp15::chr(;$); |
287
|
|
|
|
|
|
|
sub Ehp15::chr_(); |
288
|
|
|
|
|
|
|
sub Ehp15::filetest; |
289
|
|
|
|
|
|
|
sub Ehp15::r(;*@); |
290
|
|
|
|
|
|
|
sub Ehp15::w(;*@); |
291
|
|
|
|
|
|
|
sub Ehp15::x(;*@); |
292
|
|
|
|
|
|
|
sub Ehp15::o(;*@); |
293
|
|
|
|
|
|
|
sub Ehp15::R(;*@); |
294
|
|
|
|
|
|
|
sub Ehp15::W(;*@); |
295
|
|
|
|
|
|
|
sub Ehp15::X(;*@); |
296
|
|
|
|
|
|
|
sub Ehp15::O(;*@); |
297
|
|
|
|
|
|
|
sub Ehp15::e(;*@); |
298
|
|
|
|
|
|
|
sub Ehp15::z(;*@); |
299
|
|
|
|
|
|
|
sub Ehp15::s(;*@); |
300
|
|
|
|
|
|
|
sub Ehp15::f(;*@); |
301
|
|
|
|
|
|
|
sub Ehp15::d(;*@); |
302
|
|
|
|
|
|
|
sub Ehp15::l(;*@); |
303
|
|
|
|
|
|
|
sub Ehp15::p(;*@); |
304
|
|
|
|
|
|
|
sub Ehp15::S(;*@); |
305
|
|
|
|
|
|
|
sub Ehp15::b(;*@); |
306
|
|
|
|
|
|
|
sub Ehp15::c(;*@); |
307
|
|
|
|
|
|
|
sub Ehp15::u(;*@); |
308
|
|
|
|
|
|
|
sub Ehp15::g(;*@); |
309
|
|
|
|
|
|
|
sub Ehp15::k(;*@); |
310
|
|
|
|
|
|
|
sub Ehp15::T(;*@); |
311
|
|
|
|
|
|
|
sub Ehp15::B(;*@); |
312
|
|
|
|
|
|
|
sub Ehp15::M(;*@); |
313
|
|
|
|
|
|
|
sub Ehp15::A(;*@); |
314
|
|
|
|
|
|
|
sub Ehp15::C(;*@); |
315
|
|
|
|
|
|
|
sub Ehp15::filetest_; |
316
|
|
|
|
|
|
|
sub Ehp15::r_(); |
317
|
|
|
|
|
|
|
sub Ehp15::w_(); |
318
|
|
|
|
|
|
|
sub Ehp15::x_(); |
319
|
|
|
|
|
|
|
sub Ehp15::o_(); |
320
|
|
|
|
|
|
|
sub Ehp15::R_(); |
321
|
|
|
|
|
|
|
sub Ehp15::W_(); |
322
|
|
|
|
|
|
|
sub Ehp15::X_(); |
323
|
|
|
|
|
|
|
sub Ehp15::O_(); |
324
|
|
|
|
|
|
|
sub Ehp15::e_(); |
325
|
|
|
|
|
|
|
sub Ehp15::z_(); |
326
|
|
|
|
|
|
|
sub Ehp15::s_(); |
327
|
|
|
|
|
|
|
sub Ehp15::f_(); |
328
|
|
|
|
|
|
|
sub Ehp15::d_(); |
329
|
|
|
|
|
|
|
sub Ehp15::l_(); |
330
|
|
|
|
|
|
|
sub Ehp15::p_(); |
331
|
|
|
|
|
|
|
sub Ehp15::S_(); |
332
|
|
|
|
|
|
|
sub Ehp15::b_(); |
333
|
|
|
|
|
|
|
sub Ehp15::c_(); |
334
|
|
|
|
|
|
|
sub Ehp15::u_(); |
335
|
|
|
|
|
|
|
sub Ehp15::g_(); |
336
|
|
|
|
|
|
|
sub Ehp15::k_(); |
337
|
|
|
|
|
|
|
sub Ehp15::T_(); |
338
|
|
|
|
|
|
|
sub Ehp15::B_(); |
339
|
|
|
|
|
|
|
sub Ehp15::M_(); |
340
|
|
|
|
|
|
|
sub Ehp15::A_(); |
341
|
|
|
|
|
|
|
sub Ehp15::C_(); |
342
|
|
|
|
|
|
|
sub Ehp15::glob($); |
343
|
|
|
|
|
|
|
sub Ehp15::glob_(); |
344
|
|
|
|
|
|
|
sub Ehp15::lstat(*); |
345
|
|
|
|
|
|
|
sub Ehp15::lstat_(); |
346
|
|
|
|
|
|
|
sub Ehp15::opendir(*$); |
347
|
|
|
|
|
|
|
sub Ehp15::stat(*); |
348
|
|
|
|
|
|
|
sub Ehp15::stat_(); |
349
|
|
|
|
|
|
|
sub Ehp15::unlink(@); |
350
|
|
|
|
|
|
|
sub Ehp15::chdir(;$); |
351
|
|
|
|
|
|
|
sub Ehp15::do($); |
352
|
|
|
|
|
|
|
sub Ehp15::require(;$); |
353
|
|
|
|
|
|
|
sub Ehp15::telldir(*); |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub HP15::ord(;$); |
356
|
|
|
|
|
|
|
sub HP15::ord_(); |
357
|
|
|
|
|
|
|
sub HP15::reverse(@); |
358
|
|
|
|
|
|
|
sub HP15::getc(;*@); |
359
|
|
|
|
|
|
|
sub HP15::length(;$); |
360
|
|
|
|
|
|
|
sub HP15::substr($$;$$); |
361
|
|
|
|
|
|
|
sub HP15::index($$;$); |
362
|
|
|
|
|
|
|
sub HP15::rindex($$;$); |
363
|
|
|
|
|
|
|
sub HP15::escape(;$); |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
# |
366
|
|
|
|
|
|
|
# Regexp work |
367
|
|
|
|
|
|
|
# |
368
|
389
|
|
|
|
|
46021
|
use vars qw( |
369
|
|
|
|
|
|
|
$re_a |
370
|
|
|
|
|
|
|
$re_t |
371
|
|
|
|
|
|
|
$re_n |
372
|
|
|
|
|
|
|
$re_r |
373
|
389
|
|
|
389
|
|
4625
|
); |
|
389
|
|
|
|
|
803
|
|
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
# |
376
|
|
|
|
|
|
|
# Character class |
377
|
|
|
|
|
|
|
# |
378
|
389
|
|
|
|
|
106348
|
use vars qw( |
379
|
|
|
|
|
|
|
$dot |
380
|
|
|
|
|
|
|
$dot_s |
381
|
|
|
|
|
|
|
$eD |
382
|
|
|
|
|
|
|
$eS |
383
|
|
|
|
|
|
|
$eW |
384
|
|
|
|
|
|
|
$eH |
385
|
|
|
|
|
|
|
$eV |
386
|
|
|
|
|
|
|
$eR |
387
|
|
|
|
|
|
|
$eN |
388
|
|
|
|
|
|
|
$not_alnum |
389
|
|
|
|
|
|
|
$not_alpha |
390
|
|
|
|
|
|
|
$not_ascii |
391
|
|
|
|
|
|
|
$not_blank |
392
|
|
|
|
|
|
|
$not_cntrl |
393
|
|
|
|
|
|
|
$not_digit |
394
|
|
|
|
|
|
|
$not_graph |
395
|
|
|
|
|
|
|
$not_lower |
396
|
|
|
|
|
|
|
$not_lower_i |
397
|
|
|
|
|
|
|
$not_print |
398
|
|
|
|
|
|
|
$not_punct |
399
|
|
|
|
|
|
|
$not_space |
400
|
|
|
|
|
|
|
$not_upper |
401
|
|
|
|
|
|
|
$not_upper_i |
402
|
|
|
|
|
|
|
$not_word |
403
|
|
|
|
|
|
|
$not_xdigit |
404
|
|
|
|
|
|
|
$eb |
405
|
|
|
|
|
|
|
$eB |
406
|
389
|
|
|
389
|
|
5729
|
); |
|
389
|
|
|
|
|
2143
|
|
407
|
|
|
|
|
|
|
|
408
|
389
|
|
|
|
|
4769795
|
use vars qw( |
409
|
|
|
|
|
|
|
$anchor |
410
|
|
|
|
|
|
|
$matched |
411
|
389
|
|
|
389
|
|
2593
|
); |
|
389
|
|
|
|
|
2234
|
|
412
|
|
|
|
|
|
|
${Ehp15::anchor} = qr{\G(?>[^\x80-\xA0\xE0-\xFE]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])*?}oxms; |
413
|
|
|
|
|
|
|
my $q_char_SADAHIRO_Tomoyuki_2002_01_17 = ''; |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
# Quantifiers |
416
|
|
|
|
|
|
|
# {n,m} --- Match at least n but not more than m times |
417
|
|
|
|
|
|
|
# |
418
|
|
|
|
|
|
|
# n and m are limited to non-negative integral values less than a |
419
|
|
|
|
|
|
|
# preset limit defined when perl is built. This is usually 32766 on |
420
|
|
|
|
|
|
|
# the most common platforms. |
421
|
|
|
|
|
|
|
# |
422
|
|
|
|
|
|
|
# The following code is an attempt to solve the above limitations |
423
|
|
|
|
|
|
|
# in a multi-byte anchoring. |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
# avoid "Segmentation fault" and "Error: Parse exception" |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
# perl5101delta |
428
|
|
|
|
|
|
|
# http://perldoc.perl.org/perl5101delta.html |
429
|
|
|
|
|
|
|
# In 5.10.0, the * quantifier in patterns was sometimes treated as {0,32767} |
430
|
|
|
|
|
|
|
# [RT #60034, #60464]. For example, this match would fail: |
431
|
|
|
|
|
|
|
# ("ab" x 32768) =~ /^(ab)*$/ |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
# SEE ALSO |
434
|
|
|
|
|
|
|
# |
435
|
|
|
|
|
|
|
# Complex regular subexpression recursion limit |
436
|
|
|
|
|
|
|
# http://www.perlmonks.org/?node_id=810857 |
437
|
|
|
|
|
|
|
# |
438
|
|
|
|
|
|
|
# regexp iteration limits |
439
|
|
|
|
|
|
|
# http://www.nntp.perl.org/group/perl.perl5.porters/2009/02/msg144065.html |
440
|
|
|
|
|
|
|
# |
441
|
|
|
|
|
|
|
# latest Perl won't match certain regexes more than 32768 characters long |
442
|
|
|
|
|
|
|
# http://stackoverflow.com/questions/26226630/latest-perl-wont-match-certain-regexes-more-than-32768-characters-long |
443
|
|
|
|
|
|
|
# |
444
|
|
|
|
|
|
|
# Break through the limitations of regular expressions of Perl |
445
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/gfx/20110212/1297512479 |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
if (($] >= 5.010001) or |
448
|
|
|
|
|
|
|
# ActivePerl 5.6 or later (include 5.10.0) |
449
|
|
|
|
|
|
|
(defined($ActivePerl::VERSION) and ($ActivePerl::VERSION > 800)) or |
450
|
|
|
|
|
|
|
(($^O eq 'MSWin32') and ($] =~ /\A 5\.006/oxms)) |
451
|
|
|
|
|
|
|
) { |
452
|
|
|
|
|
|
|
my $sbcs = ''; # Single Byte Character Set |
453
|
|
|
|
|
|
|
for my $range (@{ $range_tr{1} }) { |
454
|
|
|
|
|
|
|
$sbcs .= sprintf('\\x%02X-\\x%02X', $range->[0], $range->[-1]); |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
if (0) { |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
# other encoding |
461
|
|
|
|
|
|
|
else { |
462
|
|
|
|
|
|
|
${Ehp15::q_char_SADAHIRO_Tomoyuki_2002_01_17} = qr{.*?[$sbcs](?:[^$sbcs][^$sbcs])*?}oxms; |
463
|
|
|
|
|
|
|
# ******* octets not in multiple octet char (always char boundary) |
464
|
|
|
|
|
|
|
# **************** 2 octet chars |
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
${Ehp15::anchor_SADAHIRO_Tomoyuki_2002_01_17} = |
468
|
|
|
|
|
|
|
qr{\G(?(?=.{0,32766}\z)(?:[^\x80-\xA0\xE0-\xFE]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])*?|(?(?=[$sbcs]+\z).*?|(?:${Ehp15::q_char_SADAHIRO_Tomoyuki_2002_01_17})))}oxms; |
469
|
|
|
|
|
|
|
# qr{ |
470
|
|
|
|
|
|
|
# \G # (1), (2) |
471
|
|
|
|
|
|
|
# (? # (3) |
472
|
|
|
|
|
|
|
# (?=.{0,32766}\z) # (4) |
473
|
|
|
|
|
|
|
# (?:[^\x80-\xA0\xE0-\xFE]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])*?| # (5) |
474
|
|
|
|
|
|
|
# (?(?=[$sbcs]+\z) # (6) |
475
|
|
|
|
|
|
|
# .*?| #(7) |
476
|
|
|
|
|
|
|
# (?:${Ehp15::q_char_SADAHIRO_Tomoyuki_2002_01_17}) # (8) |
477
|
|
|
|
|
|
|
# ))}oxms; |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
# avoid: Complex regular subexpression recursion limit (32766) exceeded at here. |
480
|
|
|
|
|
|
|
local $^W = 0; |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
if (((('A' x 32768).'B') !~ / ${Ehp15::anchor} B /oxms) and |
483
|
|
|
|
|
|
|
((('A' x 32768).'B') =~ / ${Ehp15::anchor_SADAHIRO_Tomoyuki_2002_01_17} B /oxms) |
484
|
|
|
|
|
|
|
) { |
485
|
|
|
|
|
|
|
${Ehp15::anchor} = ${Ehp15::anchor_SADAHIRO_Tomoyuki_2002_01_17}; |
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
else { |
488
|
|
|
|
|
|
|
undef ${Ehp15::q_char_SADAHIRO_Tomoyuki_2002_01_17}; |
489
|
|
|
|
|
|
|
} |
490
|
|
|
|
|
|
|
} |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
# (1) |
493
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
494
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
495
|
|
|
|
|
|
|
# in Chapter3: Over view of Regular Expression Features and Flavors |
496
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
# (2) |
499
|
|
|
|
|
|
|
# P.255 Use leading anchors |
500
|
|
|
|
|
|
|
# P.256 Expose ^ and \G at the front of expressions |
501
|
|
|
|
|
|
|
# in Chapter6: Crafting an Efficient Expression |
502
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
# (3) |
505
|
|
|
|
|
|
|
# P.138 Conditional: (? if then| else) |
506
|
|
|
|
|
|
|
# in Chapter3: Over view of Regular Expression Features and Flavors |
507
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
# (4) |
510
|
|
|
|
|
|
|
# perlre |
511
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlre.html |
512
|
|
|
|
|
|
|
# The "*" quantifier is equivalent to {0,} , the "+" quantifier to {1,} , |
513
|
|
|
|
|
|
|
# and the "?" quantifier to {0,1}, ., n, and m are limited to non-negative |
514
|
|
|
|
|
|
|
# integral values less than a preset limit defined when perl is built. |
515
|
|
|
|
|
|
|
# This is usually 32766 on the most common platforms. The actual limit |
516
|
|
|
|
|
|
|
# can be seen in the error message generated by code such as this: |
517
|
|
|
|
|
|
|
# $_ **= $_ , / {$_} / for 2 .. 42; |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
# (5) |
520
|
|
|
|
|
|
|
# P.1023 Multiple-Byte Anchoring |
521
|
|
|
|
|
|
|
# in Appendix W Perl Code Examples |
522
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
# (6) |
525
|
|
|
|
|
|
|
# if string has only SBCS (Single Byte Character Set) |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
# (7) |
528
|
|
|
|
|
|
|
# then .*? (isn't limited to 32766) |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
# (8) |
531
|
|
|
|
|
|
|
# else HP-15::Regexp::Const (SADAHIRO Tomoyuki) |
532
|
|
|
|
|
|
|
# http://homepage1.nifty.com/nomenclator/perl/shiftjis.htm#long |
533
|
|
|
|
|
|
|
# http://search.cpan.org/~sadahiro/HP-15-Regexp/ |
534
|
|
|
|
|
|
|
# $PadA = ' (?:\A| [\x00-\x80\xA0-\xDF])(?:[\x80-\xA0\xE0-\xFE]{2})*?'; |
535
|
|
|
|
|
|
|
# $PadG = '\G(?: |[\x00-\xFF]*?[\x00-\x80\xA0-\xDF])(?:[\x80-\xA0\xE0-\xFE]{2})*?'; |
536
|
|
|
|
|
|
|
# $PadGA = '\G(?:\A|(?:[\x80-\xA0\xE0-\xFE]{2})+?|[\x00-\xFF]*?[\x00-\x80\xA0-\xDF] (?:[\x80-\xA0\xE0-\xFE]{2})*?)'; |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
${Ehp15::dot} = qr{(?>[^\x80-\xA0\xE0-\xFE\x0A]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
539
|
|
|
|
|
|
|
${Ehp15::dot_s} = qr{(?>[^\x80-\xA0\xE0-\xFE]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
540
|
|
|
|
|
|
|
${Ehp15::eD} = qr{(?>[^\x80-\xA0\xE0-\xFE0-9]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
543
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
544
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
545
|
|
|
|
|
|
|
# ${Ehp15::eS} = qr{(?>[^\x80-\xA0\xE0-\xFE\x09\x0A \x0C\x0D\x20]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
546
|
|
|
|
|
|
|
# ${Ehp15::eS} = qr{(?>[^\x80-\xA0\xE0-\xFE\x09\x0A\x0B\x0C\x0D\x20]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
547
|
|
|
|
|
|
|
${Ehp15::eS} = qr{(?>[^\x80-\xA0\xE0-\xFE\s]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
${Ehp15::eW} = qr{(?>[^\x80-\xA0\xE0-\xFE0-9A-Z_a-z]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
550
|
|
|
|
|
|
|
${Ehp15::eH} = qr{(?>[^\x80-\xA0\xE0-\xFE\x09\x20]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
551
|
|
|
|
|
|
|
${Ehp15::eV} = qr{(?>[^\x80-\xA0\xE0-\xFE\x0A\x0B\x0C\x0D]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
552
|
|
|
|
|
|
|
${Ehp15::eR} = qr{(?>\x0D\x0A|[\x0A\x0D])}; |
553
|
|
|
|
|
|
|
${Ehp15::eN} = qr{(?>[^\x80-\xA0\xE0-\xFE\x0A]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
554
|
|
|
|
|
|
|
${Ehp15::not_alnum} = qr{(?>[^\x80-\xA0\xE0-\xFE\x30-\x39\x41-\x5A\x61-\x7A]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
555
|
|
|
|
|
|
|
${Ehp15::not_alpha} = qr{(?>[^\x80-\xA0\xE0-\xFE\x41-\x5A\x61-\x7A]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
556
|
|
|
|
|
|
|
${Ehp15::not_ascii} = qr{(?>[^\x80-\xA0\xE0-\xFE\x00-\x7F]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
557
|
|
|
|
|
|
|
${Ehp15::not_blank} = qr{(?>[^\x80-\xA0\xE0-\xFE\x09\x20]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
558
|
|
|
|
|
|
|
${Ehp15::not_cntrl} = qr{(?>[^\x80-\xA0\xE0-\xFE\x00-\x1F\x7F]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
559
|
|
|
|
|
|
|
${Ehp15::not_digit} = qr{(?>[^\x80-\xA0\xE0-\xFE\x30-\x39]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
560
|
|
|
|
|
|
|
${Ehp15::not_graph} = qr{(?>[^\x80-\xA0\xE0-\xFE\x21-\x7F]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
561
|
|
|
|
|
|
|
${Ehp15::not_lower} = qr{(?>[^\x80-\xA0\xE0-\xFE\x61-\x7A]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
562
|
|
|
|
|
|
|
${Ehp15::not_lower_i} = qr{(?>[^\x80-\xA0\xE0-\xFE\x41-\x5A\x61-\x7A]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; # Perl 5.16 compatible |
563
|
|
|
|
|
|
|
# ${Ehp15::not_lower_i} = qr{(?>[^\x80-\xA0\xE0-\xFE]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; # older Perl compatible |
564
|
|
|
|
|
|
|
${Ehp15::not_print} = qr{(?>[^\x80-\xA0\xE0-\xFE\x20-\x7F]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
565
|
|
|
|
|
|
|
${Ehp15::not_punct} = qr{(?>[^\x80-\xA0\xE0-\xFE\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
566
|
|
|
|
|
|
|
${Ehp15::not_space} = qr{(?>[^\x80-\xA0\xE0-\xFE\s\x0B]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
567
|
|
|
|
|
|
|
${Ehp15::not_upper} = qr{(?>[^\x80-\xA0\xE0-\xFE\x41-\x5A]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
568
|
|
|
|
|
|
|
${Ehp15::not_upper_i} = qr{(?>[^\x80-\xA0\xE0-\xFE\x41-\x5A\x61-\x7A]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; # Perl 5.16 compatible |
569
|
|
|
|
|
|
|
# ${Ehp15::not_upper_i} = qr{(?>[^\x80-\xA0\xE0-\xFE]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; # older Perl compatible |
570
|
|
|
|
|
|
|
${Ehp15::not_word} = qr{(?>[^\x80-\xA0\xE0-\xFE\x30-\x39\x41-\x5A\x5F\x61-\x7A]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
571
|
|
|
|
|
|
|
${Ehp15::not_xdigit} = qr{(?>[^\x80-\xA0\xE0-\xFE\x30-\x39\x41-\x46\x61-\x66]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])}; |
572
|
|
|
|
|
|
|
${Ehp15::eb} = qr{(?:\A(?=[0-9A-Z_a-z])|(?<=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF])(?=[0-9A-Z_a-z])|(?<=[0-9A-Z_a-z])(?=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF]|\z))}; |
573
|
|
|
|
|
|
|
${Ehp15::eB} = qr{(?:(?<=[0-9A-Z_a-z])(?=[0-9A-Z_a-z])|(?<=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF])(?=[\x00-\x2F\x40\x5B-\x5E\x60\x7B-\xFF]))}; |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
# avoid: Name "Ehp15::foo" used only once: possible typo at here. |
576
|
|
|
|
|
|
|
${Ehp15::dot} = ${Ehp15::dot}; |
577
|
|
|
|
|
|
|
${Ehp15::dot_s} = ${Ehp15::dot_s}; |
578
|
|
|
|
|
|
|
${Ehp15::eD} = ${Ehp15::eD}; |
579
|
|
|
|
|
|
|
${Ehp15::eS} = ${Ehp15::eS}; |
580
|
|
|
|
|
|
|
${Ehp15::eW} = ${Ehp15::eW}; |
581
|
|
|
|
|
|
|
${Ehp15::eH} = ${Ehp15::eH}; |
582
|
|
|
|
|
|
|
${Ehp15::eV} = ${Ehp15::eV}; |
583
|
|
|
|
|
|
|
${Ehp15::eR} = ${Ehp15::eR}; |
584
|
|
|
|
|
|
|
${Ehp15::eN} = ${Ehp15::eN}; |
585
|
|
|
|
|
|
|
${Ehp15::not_alnum} = ${Ehp15::not_alnum}; |
586
|
|
|
|
|
|
|
${Ehp15::not_alpha} = ${Ehp15::not_alpha}; |
587
|
|
|
|
|
|
|
${Ehp15::not_ascii} = ${Ehp15::not_ascii}; |
588
|
|
|
|
|
|
|
${Ehp15::not_blank} = ${Ehp15::not_blank}; |
589
|
|
|
|
|
|
|
${Ehp15::not_cntrl} = ${Ehp15::not_cntrl}; |
590
|
|
|
|
|
|
|
${Ehp15::not_digit} = ${Ehp15::not_digit}; |
591
|
|
|
|
|
|
|
${Ehp15::not_graph} = ${Ehp15::not_graph}; |
592
|
|
|
|
|
|
|
${Ehp15::not_lower} = ${Ehp15::not_lower}; |
593
|
|
|
|
|
|
|
${Ehp15::not_lower_i} = ${Ehp15::not_lower_i}; |
594
|
|
|
|
|
|
|
${Ehp15::not_print} = ${Ehp15::not_print}; |
595
|
|
|
|
|
|
|
${Ehp15::not_punct} = ${Ehp15::not_punct}; |
596
|
|
|
|
|
|
|
${Ehp15::not_space} = ${Ehp15::not_space}; |
597
|
|
|
|
|
|
|
${Ehp15::not_upper} = ${Ehp15::not_upper}; |
598
|
|
|
|
|
|
|
${Ehp15::not_upper_i} = ${Ehp15::not_upper_i}; |
599
|
|
|
|
|
|
|
${Ehp15::not_word} = ${Ehp15::not_word}; |
600
|
|
|
|
|
|
|
${Ehp15::not_xdigit} = ${Ehp15::not_xdigit}; |
601
|
|
|
|
|
|
|
${Ehp15::eb} = ${Ehp15::eb}; |
602
|
|
|
|
|
|
|
${Ehp15::eB} = ${Ehp15::eB}; |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
# |
605
|
|
|
|
|
|
|
# HP-15 split |
606
|
|
|
|
|
|
|
# |
607
|
|
|
|
|
|
|
sub Ehp15::split(;$$$) { |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
# P.794 29.2.161. split |
610
|
|
|
|
|
|
|
# in Chapter 29: Functions |
611
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
# P.951 split |
614
|
|
|
|
|
|
|
# in Chapter 27: Functions |
615
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
616
|
|
|
|
|
|
|
|
617
|
5
|
|
|
0
|
0
|
11329
|
my $pattern = $_[0]; |
618
|
0
|
|
|
|
|
0
|
my $string = $_[1]; |
619
|
0
|
|
|
|
|
0
|
my $limit = $_[2]; |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
# if $pattern is also omitted or is the literal space, " " |
622
|
0
|
0
|
|
|
|
0
|
if (not defined $pattern) { |
623
|
0
|
|
|
|
|
0
|
$pattern = ' '; |
624
|
|
|
|
|
|
|
} |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
# if $string is omitted, the function splits the $_ string |
627
|
0
|
0
|
|
|
|
0
|
if (not defined $string) { |
628
|
0
|
0
|
|
|
|
0
|
if (defined $_) { |
629
|
0
|
|
|
|
|
0
|
$string = $_; |
630
|
|
|
|
|
|
|
} |
631
|
|
|
|
|
|
|
else { |
632
|
0
|
|
|
|
|
0
|
$string = ''; |
633
|
|
|
|
|
|
|
} |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
0
|
|
|
|
|
0
|
my @split = (); |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
# when string is empty |
639
|
0
|
0
|
|
|
|
0
|
if ($string eq '') { |
|
|
0
|
|
|
|
|
|
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
# resulting list value in list context |
642
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
643
|
0
|
|
|
|
|
0
|
return @split; |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
# count of substrings in scalar context |
647
|
|
|
|
|
|
|
else { |
648
|
0
|
0
|
|
|
|
0
|
carp "Use of implicit split to \@_ is deprecated" if $^W; |
649
|
0
|
|
|
|
|
0
|
@_ = @split; |
650
|
0
|
|
|
|
|
0
|
return scalar @_; |
651
|
|
|
|
|
|
|
} |
652
|
|
|
|
|
|
|
} |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
# split's first argument is more consistently interpreted |
655
|
|
|
|
|
|
|
# |
656
|
|
|
|
|
|
|
# After some changes earlier in v5.17, split's behavior has been simplified: |
657
|
|
|
|
|
|
|
# if the PATTERN argument evaluates to a string containing one space, it is |
658
|
|
|
|
|
|
|
# treated the way that a literal string containing one space once was. |
659
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#split's_first_argument_is_more_consistently_interpreted |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
# if $pattern is also omitted or is the literal space, " ", the function splits |
662
|
|
|
|
|
|
|
# on whitespace, /\s+/, after skipping any leading whitespace |
663
|
|
|
|
|
|
|
# (and so on) |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
elsif ($pattern eq ' ') { |
666
|
0
|
0
|
|
|
|
0
|
if (not defined $limit) { |
667
|
0
|
|
|
|
|
0
|
return CORE::split(' ', $string); |
668
|
|
|
|
|
|
|
} |
669
|
|
|
|
|
|
|
else { |
670
|
0
|
|
|
|
|
0
|
return CORE::split(' ', $string, $limit); |
671
|
|
|
|
|
|
|
} |
672
|
|
|
|
|
|
|
} |
673
|
|
|
|
|
|
|
|
674
|
0
|
|
|
|
|
0
|
local $q_char = $q_char; |
675
|
0
|
0
|
|
|
|
0
|
if (CORE::length($string) > 32766) { |
676
|
0
|
0
|
|
|
|
0
|
if ($string =~ /\A [\x00-\x7F]+ \z/oxms) { |
|
|
0
|
|
|
|
|
|
677
|
0
|
|
|
|
|
0
|
$q_char = qr{.}s; |
678
|
|
|
|
|
|
|
} |
679
|
|
|
|
|
|
|
elsif (defined ${Ehp15::q_char_SADAHIRO_Tomoyuki_2002_01_17}) { |
680
|
0
|
|
|
|
|
0
|
$q_char = ${Ehp15::q_char_SADAHIRO_Tomoyuki_2002_01_17}; |
681
|
|
|
|
|
|
|
} |
682
|
|
|
|
|
|
|
} |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
# if $limit is negative, it is treated as if an arbitrarily large $limit has been specified |
685
|
0
|
0
|
0
|
|
|
0
|
if ((not defined $limit) or ($limit <= 0)) { |
|
|
0
|
|
|
|
|
|
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
# a pattern capable of matching either the null string or something longer than the |
688
|
|
|
|
|
|
|
# null string will split the value of $string into separate characters wherever it |
689
|
|
|
|
|
|
|
# matches the null string between characters |
690
|
|
|
|
|
|
|
# (and so on) |
691
|
|
|
|
|
|
|
|
692
|
0
|
0
|
|
|
|
0
|
if ('' =~ / \A $pattern \z /xms) { |
693
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
694
|
0
|
|
|
|
|
0
|
my $limit = scalar(() = $string =~ /($pattern)/oxmsg); |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
# P.1024 Appendix W.10 Multibyte Processing |
697
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
698
|
|
|
|
|
|
|
# (and so on) |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
# the //m modifier is assumed when you split on the pattern /^/ |
701
|
|
|
|
|
|
|
# (and so on) |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
# V |
704
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and ($string =~ s/\A((?:$q_char)+?)$pattern//m)) { |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
# if the $pattern contains parentheses, then the substring matched by each pair of parentheses |
707
|
|
|
|
|
|
|
# is included in the resulting list, interspersed with the fields that are ordinarily returned |
708
|
|
|
|
|
|
|
# (and so on) |
709
|
|
|
|
|
|
|
|
710
|
0
|
|
|
|
|
0
|
local $@; |
711
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
712
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
713
|
|
|
|
|
|
|
} |
714
|
|
|
|
|
|
|
} |
715
|
|
|
|
|
|
|
} |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
else { |
718
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
# V |
721
|
0
|
|
|
|
|
0
|
while ($string =~ s/\A((?:$q_char)*?)$pattern//m) { |
722
|
0
|
|
|
|
|
0
|
local $@; |
723
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
724
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
725
|
|
|
|
|
|
|
} |
726
|
|
|
|
|
|
|
} |
727
|
|
|
|
|
|
|
} |
728
|
|
|
|
|
|
|
} |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
elsif ($limit > 0) { |
731
|
0
|
0
|
|
|
|
0
|
if ('' =~ / \A $pattern \z /xms) { |
732
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
733
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and (CORE::length($string) > 0)) { |
734
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
# V |
736
|
0
|
0
|
|
|
|
0
|
if ($string =~ s/\A((?:$q_char)+?)$pattern//m) { |
737
|
0
|
|
|
|
|
0
|
local $@; |
738
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
739
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
740
|
|
|
|
|
|
|
} |
741
|
|
|
|
|
|
|
} |
742
|
|
|
|
|
|
|
} |
743
|
|
|
|
|
|
|
} |
744
|
|
|
|
|
|
|
else { |
745
|
0
|
|
|
|
|
0
|
my $last_subexpression_offsets = _last_subexpression_offsets($pattern); |
746
|
0
|
|
0
|
|
|
0
|
while ((--$limit > 0) and (CORE::length($string) > 0)) { |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
# V |
749
|
0
|
0
|
|
|
|
0
|
if ($string =~ s/\A((?:$q_char)*?)$pattern//m) { |
750
|
0
|
|
|
|
|
0
|
local $@; |
751
|
0
|
|
|
|
|
0
|
for (my $digit=1; $digit <= ($last_subexpression_offsets + 1); $digit++) { |
752
|
0
|
|
|
|
|
0
|
push @split, CORE::eval('$' . $digit); |
753
|
|
|
|
|
|
|
} |
754
|
|
|
|
|
|
|
} |
755
|
|
|
|
|
|
|
} |
756
|
|
|
|
|
|
|
} |
757
|
|
|
|
|
|
|
} |
758
|
|
|
|
|
|
|
|
759
|
0
|
0
|
|
|
|
0
|
if (CORE::length($string) > 0) { |
760
|
0
|
|
|
|
|
0
|
push @split, $string; |
761
|
|
|
|
|
|
|
} |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
# if $_[2] (NOT "$limit") is omitted or zero, trailing null fields are stripped from the result |
764
|
0
|
0
|
0
|
|
|
0
|
if ((not defined $_[2]) or ($_[2] == 0)) { |
765
|
0
|
|
0
|
|
|
0
|
while ((scalar(@split) >= 1) and ($split[-1] eq '')) { |
766
|
0
|
|
|
|
|
0
|
pop @split; |
767
|
|
|
|
|
|
|
} |
768
|
|
|
|
|
|
|
} |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
# resulting list value in list context |
771
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
772
|
0
|
|
|
|
|
0
|
return @split; |
773
|
|
|
|
|
|
|
} |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
# count of substrings in scalar context |
776
|
|
|
|
|
|
|
else { |
777
|
0
|
0
|
|
|
|
0
|
carp "Use of implicit split to \@_ is deprecated" if $^W; |
778
|
0
|
|
|
|
|
0
|
@_ = @split; |
779
|
0
|
|
|
|
|
0
|
return scalar @_; |
780
|
|
|
|
|
|
|
} |
781
|
|
|
|
|
|
|
} |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
# |
784
|
|
|
|
|
|
|
# get last subexpression offsets |
785
|
|
|
|
|
|
|
# |
786
|
|
|
|
|
|
|
sub _last_subexpression_offsets { |
787
|
0
|
|
|
0
|
|
0
|
my $pattern = $_[0]; |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
# remove comment |
790
|
0
|
|
|
|
|
0
|
$pattern =~ s/\(\?\# .*? \)//oxmsg; |
791
|
|
|
|
|
|
|
|
792
|
0
|
|
|
|
|
0
|
my $modifier = ''; |
793
|
0
|
0
|
|
|
|
0
|
if ($pattern =~ /\(\?\^? ([\-A-Za-z]+) :/oxms) { |
794
|
0
|
|
|
|
|
0
|
$modifier = $1; |
795
|
0
|
|
|
|
|
0
|
$modifier =~ s/-[A-Za-z]*//; |
796
|
|
|
|
|
|
|
} |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
# with /x modifier |
799
|
0
|
|
|
|
|
0
|
my @char = (); |
800
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /x/oxms) { |
801
|
0
|
|
|
|
|
0
|
@char = $pattern =~ /\G((?> |
802
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\#\[\(]|[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
803
|
|
|
|
|
|
|
\\ $q_char | |
804
|
|
|
|
|
|
|
\# (?>[^\n]*) $ | |
805
|
|
|
|
|
|
|
\[ (?>(?:[^\x80-\xA0\xE0-\xFE\\\]]|[\x80-\xA0\xE0-\xFE][\x00-\xFF]|\\\\|\\\]|$q_char)+) \] | |
806
|
|
|
|
|
|
|
\(\? | |
807
|
|
|
|
|
|
|
$q_char |
808
|
|
|
|
|
|
|
))/oxmsg; |
809
|
|
|
|
|
|
|
} |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
# without /x modifier |
812
|
|
|
|
|
|
|
else { |
813
|
0
|
|
|
|
|
0
|
@char = $pattern =~ /\G((?> |
814
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\[\(]|[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
815
|
|
|
|
|
|
|
\\ $q_char | |
816
|
|
|
|
|
|
|
\[ (?>(?:[^\x80-\xA0\xE0-\xFE\\\]]|[\x80-\xA0\xE0-\xFE][\x00-\xFF]|\\\\|\\\]|$q_char)+) \] | |
817
|
|
|
|
|
|
|
\(\? | |
818
|
|
|
|
|
|
|
$q_char |
819
|
|
|
|
|
|
|
))/oxmsg; |
820
|
|
|
|
|
|
|
} |
821
|
|
|
|
|
|
|
|
822
|
0
|
|
|
|
|
0
|
return scalar grep { $_ eq '(' } @char; |
|
0
|
|
|
|
|
0
|
|
823
|
|
|
|
|
|
|
} |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
# |
826
|
|
|
|
|
|
|
# HP-15 transliteration (tr///) |
827
|
|
|
|
|
|
|
# |
828
|
|
|
|
|
|
|
sub Ehp15::tr($$$$;$) { |
829
|
|
|
|
|
|
|
|
830
|
0
|
|
|
0
|
0
|
0
|
my $bind_operator = $_[1]; |
831
|
0
|
|
|
|
|
0
|
my $searchlist = $_[2]; |
832
|
0
|
|
|
|
|
0
|
my $replacementlist = $_[3]; |
833
|
0
|
|
0
|
|
|
0
|
my $modifier = $_[4] || ''; |
834
|
|
|
|
|
|
|
|
835
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /r/oxms) { |
836
|
0
|
0
|
|
|
|
0
|
if ($bind_operator =~ / !~ /oxms) { |
837
|
0
|
|
|
|
|
0
|
croak "Using !~ with tr///r doesn't make sense"; |
838
|
|
|
|
|
|
|
} |
839
|
|
|
|
|
|
|
} |
840
|
|
|
|
|
|
|
|
841
|
0
|
|
|
|
|
0
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
842
|
0
|
|
|
|
|
0
|
my @searchlist = _charlist_tr($searchlist); |
843
|
0
|
|
|
|
|
0
|
my @replacementlist = _charlist_tr($replacementlist); |
844
|
|
|
|
|
|
|
|
845
|
0
|
|
|
|
|
0
|
my %tr = (); |
846
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#searchlist; $i++) { |
847
|
0
|
0
|
|
|
|
0
|
if (not exists $tr{$searchlist[$i]}) { |
848
|
0
|
0
|
0
|
|
|
0
|
if (defined $replacementlist[$i] and ($replacementlist[$i] ne '')) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
849
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $replacementlist[$i]; |
850
|
|
|
|
|
|
|
} |
851
|
|
|
|
|
|
|
elsif ($modifier =~ /d/oxms) { |
852
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = ''; |
853
|
|
|
|
|
|
|
} |
854
|
|
|
|
|
|
|
elsif (defined $replacementlist[-1] and ($replacementlist[-1] ne '')) { |
855
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $replacementlist[-1]; |
856
|
|
|
|
|
|
|
} |
857
|
|
|
|
|
|
|
else { |
858
|
0
|
|
|
|
|
0
|
$tr{$searchlist[$i]} = $searchlist[$i]; |
859
|
|
|
|
|
|
|
} |
860
|
|
|
|
|
|
|
} |
861
|
|
|
|
|
|
|
} |
862
|
|
|
|
|
|
|
|
863
|
0
|
|
|
|
|
0
|
my $tr = 0; |
864
|
0
|
|
|
|
|
0
|
my $replaced = ''; |
865
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /c/oxms) { |
866
|
0
|
|
|
|
|
0
|
while (defined(my $char = shift @char)) { |
867
|
0
|
0
|
|
|
|
0
|
if (not exists $tr{$char}) { |
868
|
0
|
0
|
|
|
|
0
|
if (defined $replacementlist[0]) { |
869
|
0
|
|
|
|
|
0
|
$replaced .= $replacementlist[0]; |
870
|
|
|
|
|
|
|
} |
871
|
0
|
|
|
|
|
0
|
$tr++; |
872
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /s/oxms) { |
873
|
0
|
|
0
|
|
|
0
|
while (@char and (not exists $tr{$char[0]})) { |
874
|
0
|
|
|
|
|
0
|
shift @char; |
875
|
0
|
|
|
|
|
0
|
$tr++; |
876
|
|
|
|
|
|
|
} |
877
|
|
|
|
|
|
|
} |
878
|
|
|
|
|
|
|
} |
879
|
|
|
|
|
|
|
else { |
880
|
0
|
|
|
|
|
0
|
$replaced .= $char; |
881
|
|
|
|
|
|
|
} |
882
|
|
|
|
|
|
|
} |
883
|
|
|
|
|
|
|
} |
884
|
|
|
|
|
|
|
else { |
885
|
0
|
|
|
|
|
0
|
while (defined(my $char = shift @char)) { |
886
|
0
|
0
|
|
|
|
0
|
if (exists $tr{$char}) { |
887
|
0
|
|
|
|
|
0
|
$replaced .= $tr{$char}; |
888
|
0
|
|
|
|
|
0
|
$tr++; |
889
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /s/oxms) { |
890
|
0
|
|
0
|
|
|
0
|
while (@char and (exists $tr{$char[0]}) and ($tr{$char[0]} eq $tr{$char})) { |
|
|
|
0
|
|
|
|
|
891
|
0
|
|
|
|
|
0
|
shift @char; |
892
|
0
|
|
|
|
|
0
|
$tr++; |
893
|
|
|
|
|
|
|
} |
894
|
|
|
|
|
|
|
} |
895
|
|
|
|
|
|
|
} |
896
|
|
|
|
|
|
|
else { |
897
|
0
|
|
|
|
|
0
|
$replaced .= $char; |
898
|
|
|
|
|
|
|
} |
899
|
|
|
|
|
|
|
} |
900
|
|
|
|
|
|
|
} |
901
|
|
|
|
|
|
|
|
902
|
0
|
0
|
|
|
|
0
|
if ($modifier =~ /r/oxms) { |
903
|
0
|
|
|
|
|
0
|
return $replaced; |
904
|
|
|
|
|
|
|
} |
905
|
|
|
|
|
|
|
else { |
906
|
0
|
|
|
|
|
0
|
$_[0] = $replaced; |
907
|
0
|
0
|
|
|
|
0
|
if ($bind_operator =~ / !~ /oxms) { |
908
|
0
|
|
|
|
|
0
|
return not $tr; |
909
|
|
|
|
|
|
|
} |
910
|
|
|
|
|
|
|
else { |
911
|
0
|
|
|
|
|
0
|
return $tr; |
912
|
|
|
|
|
|
|
} |
913
|
|
|
|
|
|
|
} |
914
|
|
|
|
|
|
|
} |
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
# |
917
|
|
|
|
|
|
|
# HP-15 chop |
918
|
|
|
|
|
|
|
# |
919
|
|
|
|
|
|
|
sub Ehp15::chop(@) { |
920
|
|
|
|
|
|
|
|
921
|
0
|
|
|
0
|
0
|
0
|
my $chop; |
922
|
0
|
0
|
|
|
|
0
|
if (@_ == 0) { |
923
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
924
|
0
|
|
|
|
|
0
|
$chop = pop @char; |
925
|
0
|
|
|
|
|
0
|
$_ = join '', @char; |
926
|
|
|
|
|
|
|
} |
927
|
|
|
|
|
|
|
else { |
928
|
0
|
|
|
|
|
0
|
for (@_) { |
929
|
0
|
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
930
|
0
|
|
|
|
|
0
|
$chop = pop @char; |
931
|
0
|
|
|
|
|
0
|
$_ = join '', @char; |
932
|
|
|
|
|
|
|
} |
933
|
|
|
|
|
|
|
} |
934
|
0
|
|
|
|
|
0
|
return $chop; |
935
|
|
|
|
|
|
|
} |
936
|
|
|
|
|
|
|
|
937
|
|
|
|
|
|
|
# |
938
|
|
|
|
|
|
|
# HP-15 index by octet |
939
|
|
|
|
|
|
|
# |
940
|
|
|
|
|
|
|
sub Ehp15::index($$;$) { |
941
|
|
|
|
|
|
|
|
942
|
0
|
|
|
2304
|
1
|
0
|
my($str,$substr,$position) = @_; |
943
|
2304
|
|
50
|
|
|
5151
|
$position ||= 0; |
944
|
2304
|
|
|
|
|
8493
|
my $pos = 0; |
945
|
|
|
|
|
|
|
|
946
|
2304
|
|
|
|
|
3146
|
while ($pos < CORE::length($str)) { |
947
|
2304
|
50
|
|
|
|
5563
|
if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) { |
948
|
52332
|
0
|
|
|
|
77269
|
if ($pos >= $position) { |
949
|
0
|
|
|
|
|
0
|
return $pos; |
950
|
|
|
|
|
|
|
} |
951
|
|
|
|
|
|
|
} |
952
|
0
|
50
|
|
|
|
0
|
if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) { |
953
|
52332
|
|
|
|
|
117175
|
$pos += CORE::length($1); |
954
|
|
|
|
|
|
|
} |
955
|
|
|
|
|
|
|
else { |
956
|
52332
|
|
|
|
|
96274
|
$pos += 1; |
957
|
|
|
|
|
|
|
} |
958
|
|
|
|
|
|
|
} |
959
|
0
|
|
|
|
|
0
|
return -1; |
960
|
|
|
|
|
|
|
} |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
# |
963
|
|
|
|
|
|
|
# HP-15 reverse index |
964
|
|
|
|
|
|
|
# |
965
|
|
|
|
|
|
|
sub Ehp15::rindex($$;$) { |
966
|
|
|
|
|
|
|
|
967
|
2304
|
|
|
0
|
0
|
15796
|
my($str,$substr,$position) = @_; |
968
|
0
|
|
0
|
|
|
0
|
$position ||= CORE::length($str) - 1; |
969
|
0
|
|
|
|
|
0
|
my $pos = 0; |
970
|
0
|
|
|
|
|
0
|
my $rindex = -1; |
971
|
|
|
|
|
|
|
|
972
|
0
|
|
0
|
|
|
0
|
while (($pos < CORE::length($str)) and ($pos <= $position)) { |
973
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos,CORE::length($substr)) eq $substr) { |
974
|
0
|
|
|
|
|
0
|
$rindex = $pos; |
975
|
|
|
|
|
|
|
} |
976
|
0
|
0
|
|
|
|
0
|
if (CORE::substr($str,$pos) =~ /\A ($q_char) /oxms) { |
977
|
0
|
|
|
|
|
0
|
$pos += CORE::length($1); |
978
|
|
|
|
|
|
|
} |
979
|
|
|
|
|
|
|
else { |
980
|
0
|
|
|
|
|
0
|
$pos += 1; |
981
|
|
|
|
|
|
|
} |
982
|
|
|
|
|
|
|
} |
983
|
0
|
|
|
|
|
0
|
return $rindex; |
984
|
|
|
|
|
|
|
} |
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
# |
987
|
|
|
|
|
|
|
# HP-15 lower case first with parameter |
988
|
|
|
|
|
|
|
# |
989
|
|
|
|
|
|
|
sub Ehp15::lcfirst(@) { |
990
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
991
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
992
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
993
|
0
|
|
|
|
|
0
|
return Ehp15::lc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_; |
994
|
|
|
|
|
|
|
} |
995
|
|
|
|
|
|
|
else { |
996
|
0
|
|
|
|
|
0
|
return Ehp15::lc(CORE::substr($s,0,1)) . CORE::substr($s,1); |
997
|
|
|
|
|
|
|
} |
998
|
|
|
|
|
|
|
} |
999
|
|
|
|
|
|
|
else { |
1000
|
0
|
|
|
|
|
0
|
return Ehp15::lc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1001
|
|
|
|
|
|
|
} |
1002
|
|
|
|
|
|
|
} |
1003
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
# |
1005
|
|
|
|
|
|
|
# HP-15 lower case first without parameter |
1006
|
|
|
|
|
|
|
# |
1007
|
|
|
|
|
|
|
sub Ehp15::lcfirst_() { |
1008
|
0
|
|
|
0
|
0
|
0
|
return Ehp15::lc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1009
|
|
|
|
|
|
|
} |
1010
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
# |
1012
|
|
|
|
|
|
|
# HP-15 lower case with parameter |
1013
|
|
|
|
|
|
|
# |
1014
|
|
|
|
|
|
|
sub Ehp15::lc(@) { |
1015
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
1016
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
1017
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
1018
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1019
|
|
|
|
|
|
|
} |
1020
|
|
|
|
|
|
|
else { |
1021
|
0
|
0
|
|
|
|
0
|
return join('', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
0
|
|
|
|
|
0
|
|
1022
|
|
|
|
|
|
|
} |
1023
|
|
|
|
|
|
|
} |
1024
|
|
|
|
|
|
|
else { |
1025
|
0
|
|
|
|
|
0
|
return Ehp15::lc_(); |
1026
|
|
|
|
|
|
|
} |
1027
|
|
|
|
|
|
|
} |
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
# |
1030
|
|
|
|
|
|
|
# HP-15 lower case without parameter |
1031
|
|
|
|
|
|
|
# |
1032
|
|
|
|
|
|
|
sub Ehp15::lc_() { |
1033
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1034
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($lc{$_}) ? $lc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1035
|
|
|
|
|
|
|
} |
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
# |
1038
|
|
|
|
|
|
|
# HP-15 upper case first with parameter |
1039
|
|
|
|
|
|
|
# |
1040
|
|
|
|
|
|
|
sub Ehp15::ucfirst(@) { |
1041
|
0
|
0
|
|
0
|
0
|
0
|
if (@_) { |
1042
|
0
|
|
|
|
|
0
|
my $s = shift @_; |
1043
|
0
|
0
|
0
|
|
|
0
|
if (@_ and wantarray) { |
1044
|
0
|
|
|
|
|
0
|
return Ehp15::uc(CORE::substr($s,0,1)) . CORE::substr($s,1), @_; |
1045
|
|
|
|
|
|
|
} |
1046
|
|
|
|
|
|
|
else { |
1047
|
0
|
|
|
|
|
0
|
return Ehp15::uc(CORE::substr($s,0,1)) . CORE::substr($s,1); |
1048
|
|
|
|
|
|
|
} |
1049
|
|
|
|
|
|
|
} |
1050
|
|
|
|
|
|
|
else { |
1051
|
0
|
|
|
|
|
0
|
return Ehp15::uc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1052
|
|
|
|
|
|
|
} |
1053
|
|
|
|
|
|
|
} |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
# |
1056
|
|
|
|
|
|
|
# HP-15 upper case first without parameter |
1057
|
|
|
|
|
|
|
# |
1058
|
|
|
|
|
|
|
sub Ehp15::ucfirst_() { |
1059
|
0
|
|
|
0
|
0
|
0
|
return Ehp15::uc(CORE::substr($_,0,1)) . CORE::substr($_,1); |
1060
|
|
|
|
|
|
|
} |
1061
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
# |
1063
|
|
|
|
|
|
|
# HP-15 upper case with parameter |
1064
|
|
|
|
|
|
|
# |
1065
|
|
|
|
|
|
|
sub Ehp15::uc(@) { |
1066
|
0
|
50
|
|
3588
|
0
|
0
|
if (@_) { |
1067
|
3588
|
|
|
|
|
5401
|
my $s = shift @_; |
1068
|
3588
|
50
|
33
|
|
|
4585
|
if (@_ and wantarray) { |
1069
|
3588
|
0
|
|
|
|
6387
|
return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1070
|
|
|
|
|
|
|
} |
1071
|
|
|
|
|
|
|
else { |
1072
|
0
|
100
|
|
|
|
0
|
return join('', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
3588
|
|
|
|
|
10158
|
|
1073
|
|
|
|
|
|
|
} |
1074
|
|
|
|
|
|
|
} |
1075
|
|
|
|
|
|
|
else { |
1076
|
3588
|
|
|
|
|
12286
|
return Ehp15::uc_(); |
1077
|
|
|
|
|
|
|
} |
1078
|
|
|
|
|
|
|
} |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
# |
1081
|
|
|
|
|
|
|
# HP-15 upper case without parameter |
1082
|
|
|
|
|
|
|
# |
1083
|
|
|
|
|
|
|
sub Ehp15::uc_() { |
1084
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1085
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($uc{$_}) ? $uc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1086
|
|
|
|
|
|
|
} |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
# |
1089
|
|
|
|
|
|
|
# HP-15 fold case with parameter |
1090
|
|
|
|
|
|
|
# |
1091
|
|
|
|
|
|
|
sub Ehp15::fc(@) { |
1092
|
0
|
50
|
|
3891
|
0
|
0
|
if (@_) { |
1093
|
3891
|
|
|
|
|
5689
|
my $s = shift @_; |
1094
|
3891
|
50
|
33
|
|
|
5032
|
if (@_ and wantarray) { |
1095
|
3891
|
0
|
|
|
|
6737
|
return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)), @_; |
|
0
|
|
|
|
|
0
|
|
1096
|
|
|
|
|
|
|
} |
1097
|
|
|
|
|
|
|
else { |
1098
|
0
|
100
|
|
|
|
0
|
return join('', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg)); |
|
3891
|
|
|
|
|
10153
|
|
1099
|
|
|
|
|
|
|
} |
1100
|
|
|
|
|
|
|
} |
1101
|
|
|
|
|
|
|
else { |
1102
|
3891
|
|
|
|
|
14078
|
return Ehp15::fc_(); |
1103
|
|
|
|
|
|
|
} |
1104
|
|
|
|
|
|
|
} |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
# |
1107
|
|
|
|
|
|
|
# HP-15 fold case without parameter |
1108
|
|
|
|
|
|
|
# |
1109
|
|
|
|
|
|
|
sub Ehp15::fc_() { |
1110
|
0
|
|
|
0
|
0
|
0
|
my $s = $_; |
1111
|
0
|
0
|
|
|
|
0
|
return join '', map {defined($fc{$_}) ? $fc{$_} : $_} ($s =~ /\G ($q_char) /oxmsg); |
|
0
|
|
|
|
|
0
|
|
1112
|
|
|
|
|
|
|
} |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
# |
1115
|
|
|
|
|
|
|
# HP-15 regexp capture |
1116
|
|
|
|
|
|
|
# |
1117
|
|
|
|
|
|
|
{ |
1118
|
|
|
|
|
|
|
# 10.3. Creating Persistent Private Variables |
1119
|
|
|
|
|
|
|
# in Chapter 10. Subroutines |
1120
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
my $last_s_matched = 0; |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
sub Ehp15::capture { |
1125
|
0
|
0
|
0
|
0
|
1
|
0
|
if ($last_s_matched and ($_[0] =~ /\A (?>[1-9][0-9]*) \z/oxms)) { |
1126
|
0
|
|
|
|
|
0
|
return $_[0] + 1; |
1127
|
|
|
|
|
|
|
} |
1128
|
0
|
|
|
|
|
0
|
return $_[0]; |
1129
|
|
|
|
|
|
|
} |
1130
|
|
|
|
|
|
|
|
1131
|
|
|
|
|
|
|
# HP-15 mark last regexp matched |
1132
|
|
|
|
|
|
|
sub Ehp15::matched() { |
1133
|
0
|
|
|
0
|
0
|
0
|
$last_s_matched = 0; |
1134
|
|
|
|
|
|
|
} |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
# HP-15 mark last s/// matched |
1137
|
|
|
|
|
|
|
sub Ehp15::s_matched() { |
1138
|
0
|
|
|
0
|
0
|
0
|
$last_s_matched = 1; |
1139
|
|
|
|
|
|
|
} |
1140
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
# P.854 31.17. use re |
1142
|
|
|
|
|
|
|
# in Chapter 31. Pragmatic Modules |
1143
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1144
|
|
|
|
|
|
|
|
1145
|
|
|
|
|
|
|
# P.1026 re |
1146
|
|
|
|
|
|
|
# in Chapter 29. Pragmatic Modules |
1147
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1148
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
$Ehp15::matched = qr/(?{Ehp15::matched})/; |
1150
|
|
|
|
|
|
|
} |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
# |
1153
|
|
|
|
|
|
|
# HP-15 regexp ignore case modifier |
1154
|
|
|
|
|
|
|
# |
1155
|
|
|
|
|
|
|
sub Ehp15::ignorecase { |
1156
|
|
|
|
|
|
|
|
1157
|
0
|
|
|
0
|
0
|
0
|
my @string = @_; |
1158
|
0
|
|
|
|
|
0
|
my $metachar = qr/[\@\\|[\]{]/oxms; |
1159
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
# ignore case of $scalar or @array |
1161
|
0
|
|
|
|
|
0
|
for my $string (@string) { |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
# split regexp |
1164
|
0
|
|
|
|
|
0
|
my @char = $string =~ /\G (?>\[\^|\\$q_char|$q_char) /oxmsg; |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
# unescape character |
1167
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#char; $i++) { |
1168
|
0
|
0
|
|
|
|
0
|
next if not defined $char[$i]; |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
# open character class [...] |
1171
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '[') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1172
|
0
|
|
|
|
|
0
|
my $left = $i; |
1173
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
# [] make die "unmatched [] in regexp ...\n" |
1175
|
|
|
|
|
|
|
|
1176
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
1177
|
0
|
|
|
|
|
0
|
$i++; |
1178
|
|
|
|
|
|
|
} |
1179
|
|
|
|
|
|
|
|
1180
|
0
|
|
|
|
|
0
|
while (1) { |
1181
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
1182
|
0
|
|
|
|
|
0
|
croak "Unmatched [] in regexp"; |
1183
|
|
|
|
|
|
|
} |
1184
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
1185
|
0
|
|
|
|
|
0
|
my $right = $i; |
1186
|
0
|
|
|
|
|
0
|
my @charlist = charlist_qr(@char[$left+1..$right-1], 'i'); |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
# escape character |
1189
|
0
|
|
|
|
|
0
|
for my $char (@charlist) { |
1190
|
0
|
0
|
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
} |
1192
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
# do not use quotemeta here |
1194
|
0
|
|
|
|
|
0
|
elsif ($char =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1195
|
0
|
|
|
|
|
0
|
$char = $1 . '\\' . $2; |
1196
|
|
|
|
|
|
|
} |
1197
|
|
|
|
|
|
|
elsif ($char =~ /\A [.|)] \z/oxms) { |
1198
|
0
|
|
|
|
|
0
|
$char = '\\' . $char; |
1199
|
|
|
|
|
|
|
} |
1200
|
|
|
|
|
|
|
} |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
# [...] |
1203
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, '(?:' . join('|', @charlist) . ')'; |
1204
|
|
|
|
|
|
|
|
1205
|
0
|
|
|
|
|
0
|
$i = $left; |
1206
|
0
|
|
|
|
|
0
|
last; |
1207
|
|
|
|
|
|
|
} |
1208
|
|
|
|
|
|
|
} |
1209
|
|
|
|
|
|
|
} |
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
# open character class [^...] |
1212
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
1213
|
0
|
|
|
|
|
0
|
my $left = $i; |
1214
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
# [^] make die "unmatched [] in regexp ...\n" |
1216
|
|
|
|
|
|
|
|
1217
|
0
|
0
|
|
|
|
0
|
if ($char[$i+1] eq ']') { |
1218
|
0
|
|
|
|
|
0
|
$i++; |
1219
|
|
|
|
|
|
|
} |
1220
|
|
|
|
|
|
|
|
1221
|
0
|
|
|
|
|
0
|
while (1) { |
1222
|
0
|
0
|
|
|
|
0
|
if (++$i > $#char) { |
1223
|
0
|
|
|
|
|
0
|
croak "Unmatched [] in regexp"; |
1224
|
|
|
|
|
|
|
} |
1225
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq ']') { |
1226
|
0
|
|
|
|
|
0
|
my $right = $i; |
1227
|
0
|
|
|
|
|
0
|
my @charlist = charlist_not_qr(@char[$left+1..$right-1], 'i'); |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
# escape character |
1230
|
0
|
|
|
|
|
0
|
for my $char (@charlist) { |
1231
|
0
|
0
|
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1232
|
|
|
|
|
|
|
} |
1233
|
|
|
|
|
|
|
|
1234
|
|
|
|
|
|
|
# do not use quotemeta here |
1235
|
0
|
|
|
|
|
0
|
elsif ($char =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1236
|
0
|
|
|
|
|
0
|
$char = $1 . '\\' . $2; |
1237
|
|
|
|
|
|
|
} |
1238
|
|
|
|
|
|
|
elsif ($char =~ /\A [.|)] \z/oxms) { |
1239
|
0
|
|
|
|
|
0
|
$char = '\\' . $char; |
1240
|
|
|
|
|
|
|
} |
1241
|
|
|
|
|
|
|
} |
1242
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
# [^...] |
1244
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, '(?!' . join('|', @charlist) . ")(?:$your_char)"; |
1245
|
|
|
|
|
|
|
|
1246
|
0
|
|
|
|
|
0
|
$i = $left; |
1247
|
0
|
|
|
|
|
0
|
last; |
1248
|
|
|
|
|
|
|
} |
1249
|
|
|
|
|
|
|
} |
1250
|
|
|
|
|
|
|
} |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
# rewrite classic character class or escape character |
1253
|
|
|
|
|
|
|
elsif (my $char = classic_character_class($char[$i])) { |
1254
|
0
|
|
|
|
|
0
|
$char[$i] = $char; |
1255
|
|
|
|
|
|
|
} |
1256
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
# with /i modifier |
1258
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) { |
1259
|
0
|
|
|
|
|
0
|
my $uc = Ehp15::uc($char[$i]); |
1260
|
0
|
|
|
|
|
0
|
my $fc = Ehp15::fc($char[$i]); |
1261
|
0
|
0
|
|
|
|
0
|
if ($uc ne $fc) { |
1262
|
0
|
0
|
|
|
|
0
|
if (CORE::length($fc) == 1) { |
1263
|
0
|
|
|
|
|
0
|
$char[$i] = '[' . $uc . $fc . ']'; |
1264
|
|
|
|
|
|
|
} |
1265
|
|
|
|
|
|
|
else { |
1266
|
0
|
|
|
|
|
0
|
$char[$i] = '(?:' . $uc . '|' . $fc . ')'; |
1267
|
|
|
|
|
|
|
} |
1268
|
|
|
|
|
|
|
} |
1269
|
|
|
|
|
|
|
} |
1270
|
|
|
|
|
|
|
} |
1271
|
|
|
|
|
|
|
|
1272
|
|
|
|
|
|
|
# characterize |
1273
|
0
|
|
|
|
|
0
|
for (my $i=0; $i <= $#char; $i++) { |
1274
|
0
|
0
|
|
|
|
0
|
next if not defined $char[$i]; |
1275
|
|
|
|
|
|
|
|
1276
|
0
|
0
|
0
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
1277
|
|
|
|
|
|
|
} |
1278
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
1280
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
1281
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
1282
|
|
|
|
|
|
|
} |
1283
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
# quote character before ? + * { |
1285
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
1286
|
0
|
0
|
|
|
|
0
|
if ($char[$i-1] !~ /\A [\x00-\xFF] \z/oxms) { |
1287
|
0
|
|
|
|
|
0
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
1288
|
|
|
|
|
|
|
} |
1289
|
|
|
|
|
|
|
} |
1290
|
|
|
|
|
|
|
} |
1291
|
|
|
|
|
|
|
|
1292
|
0
|
|
|
|
|
0
|
$string = join '', @char; |
1293
|
|
|
|
|
|
|
} |
1294
|
|
|
|
|
|
|
|
1295
|
|
|
|
|
|
|
# make regexp string |
1296
|
0
|
|
|
|
|
0
|
return @string; |
1297
|
|
|
|
|
|
|
} |
1298
|
|
|
|
|
|
|
|
1299
|
|
|
|
|
|
|
# |
1300
|
|
|
|
|
|
|
# classic character class ( \D \S \W \d \s \w \C \X \H \V \h \v \R \N \b \B ) |
1301
|
|
|
|
|
|
|
# |
1302
|
|
|
|
|
|
|
sub Ehp15::classic_character_class { |
1303
|
0
|
|
|
5227
|
0
|
0
|
my($char) = @_; |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
return { |
1306
|
|
|
|
|
|
|
'\D' => '${Ehp15::eD}', |
1307
|
|
|
|
|
|
|
'\S' => '${Ehp15::eS}', |
1308
|
|
|
|
|
|
|
'\W' => '${Ehp15::eW}', |
1309
|
|
|
|
|
|
|
'\d' => '[0-9]', |
1310
|
|
|
|
|
|
|
|
1311
|
|
|
|
|
|
|
# Before Perl 5.6, \s only matched the five whitespace characters |
1312
|
|
|
|
|
|
|
# tab, newline, form-feed, carriage return, and the space character |
1313
|
|
|
|
|
|
|
# itself, which, taken together, is the character class [\t\n\f\r ]. |
1314
|
|
|
|
|
|
|
|
1315
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
1316
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
1317
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
1318
|
|
|
|
|
|
|
# \t \n \v \f \r space |
1319
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A \x0C\x0D\x20]', |
1320
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]', |
1321
|
|
|
|
|
|
|
'\s' => '\s', |
1322
|
|
|
|
|
|
|
|
1323
|
|
|
|
|
|
|
'\w' => '[0-9A-Z_a-z]', |
1324
|
|
|
|
|
|
|
'\C' => '[\x00-\xFF]', |
1325
|
|
|
|
|
|
|
'\X' => 'X', |
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
# \h \v \H \V |
1328
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
# P.114 Character Class Shortcuts |
1330
|
|
|
|
|
|
|
# in Chapter 7: In the World of Regular Expressions |
1331
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
1332
|
|
|
|
|
|
|
|
1333
|
|
|
|
|
|
|
# P.357 13.2.3 Whitespace |
1334
|
|
|
|
|
|
|
# in Chapter 13: perlrecharclass: Perl Regular Expression Character Classes |
1335
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
1336
|
|
|
|
|
|
|
# |
1337
|
|
|
|
|
|
|
# 0x00009 CHARACTER TABULATION h s |
1338
|
|
|
|
|
|
|
# 0x0000a LINE FEED (LF) vs |
1339
|
|
|
|
|
|
|
# 0x0000b LINE TABULATION v |
1340
|
|
|
|
|
|
|
# 0x0000c FORM FEED (FF) vs |
1341
|
|
|
|
|
|
|
# 0x0000d CARRIAGE RETURN (CR) vs |
1342
|
|
|
|
|
|
|
# 0x00020 SPACE h s |
1343
|
|
|
|
|
|
|
|
1344
|
|
|
|
|
|
|
# P.196 Table 5-9. Alphanumeric regex metasymbols |
1345
|
|
|
|
|
|
|
# in Chapter 5. Pattern Matching |
1346
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1347
|
|
|
|
|
|
|
|
1348
|
|
|
|
|
|
|
# (and so on) |
1349
|
|
|
|
|
|
|
|
1350
|
|
|
|
|
|
|
'\H' => '${Ehp15::eH}', |
1351
|
|
|
|
|
|
|
'\V' => '${Ehp15::eV}', |
1352
|
|
|
|
|
|
|
'\h' => '[\x09\x20]', |
1353
|
|
|
|
|
|
|
'\v' => '[\x0A\x0B\x0C\x0D]', |
1354
|
|
|
|
|
|
|
'\R' => '${Ehp15::eR}', |
1355
|
|
|
|
|
|
|
|
1356
|
|
|
|
|
|
|
# \N |
1357
|
|
|
|
|
|
|
# |
1358
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlre.html |
1359
|
|
|
|
|
|
|
# Character Classes and other Special Escapes |
1360
|
|
|
|
|
|
|
# Any character but \n (experimental). Not affected by /s modifier |
1361
|
|
|
|
|
|
|
|
1362
|
|
|
|
|
|
|
'\N' => '${Ehp15::eN}', |
1363
|
|
|
|
|
|
|
|
1364
|
|
|
|
|
|
|
# \b \B |
1365
|
|
|
|
|
|
|
|
1366
|
|
|
|
|
|
|
# P.180 Boundaries: The \b and \B Assertions |
1367
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1368
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
# P.219 Boundaries: The \b and \B Assertions |
1371
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
1372
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
1373
|
|
|
|
|
|
|
|
1374
|
|
|
|
|
|
|
# \b really means (?:(?<=\w)(?!\w)|(?
|
1375
|
|
|
|
|
|
|
# or (?:(?<=\A|\W)(?=\w)|(?<=\w)(?=\W|\z)) |
1376
|
|
|
|
|
|
|
'\b' => '${Ehp15::eb}', |
1377
|
|
|
|
|
|
|
|
1378
|
|
|
|
|
|
|
# \B really means (?:(?<=\w)(?=\w)|(?
|
1379
|
|
|
|
|
|
|
# or (?:(?<=\w)(?=\w)|(?<=\W)(?=\W)) |
1380
|
|
|
|
|
|
|
'\B' => '${Ehp15::eB}', |
1381
|
|
|
|
|
|
|
|
1382
|
5227
|
|
100
|
|
|
7370
|
}->{$char} || ''; |
1383
|
|
|
|
|
|
|
} |
1384
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
# |
1386
|
|
|
|
|
|
|
# prepare HP-15 characters per length |
1387
|
|
|
|
|
|
|
# |
1388
|
|
|
|
|
|
|
|
1389
|
|
|
|
|
|
|
# 1 octet characters |
1390
|
|
|
|
|
|
|
my @chars1 = (); |
1391
|
|
|
|
|
|
|
sub chars1 { |
1392
|
5227
|
0
|
|
0
|
0
|
171523
|
if (@chars1) { |
1393
|
0
|
|
|
|
|
0
|
return @chars1; |
1394
|
|
|
|
|
|
|
} |
1395
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{1}) { |
1396
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{1} }; |
|
0
|
|
|
|
|
0
|
|
1397
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,1)) { |
1398
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1399
|
0
|
|
|
|
|
0
|
push @chars1, pack 'C', $oct0; |
1400
|
|
|
|
|
|
|
} |
1401
|
|
|
|
|
|
|
} |
1402
|
|
|
|
|
|
|
} |
1403
|
0
|
|
|
|
|
0
|
return @chars1; |
1404
|
|
|
|
|
|
|
} |
1405
|
|
|
|
|
|
|
|
1406
|
|
|
|
|
|
|
# 2 octets characters |
1407
|
|
|
|
|
|
|
my @chars2 = (); |
1408
|
|
|
|
|
|
|
sub chars2 { |
1409
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars2) { |
1410
|
0
|
|
|
|
|
0
|
return @chars2; |
1411
|
|
|
|
|
|
|
} |
1412
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{2}) { |
1413
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{2} }; |
|
0
|
|
|
|
|
0
|
|
1414
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,2)) { |
1415
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1416
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1417
|
0
|
|
|
|
|
0
|
push @chars2, pack 'CC', $oct0,$oct1; |
1418
|
|
|
|
|
|
|
} |
1419
|
|
|
|
|
|
|
} |
1420
|
|
|
|
|
|
|
} |
1421
|
|
|
|
|
|
|
} |
1422
|
0
|
|
|
|
|
0
|
return @chars2; |
1423
|
|
|
|
|
|
|
} |
1424
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
# 3 octets characters |
1426
|
|
|
|
|
|
|
my @chars3 = (); |
1427
|
|
|
|
|
|
|
sub chars3 { |
1428
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars3) { |
1429
|
0
|
|
|
|
|
0
|
return @chars3; |
1430
|
|
|
|
|
|
|
} |
1431
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{3}) { |
1432
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{3} }; |
|
0
|
|
|
|
|
0
|
|
1433
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,3)) { |
1434
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1435
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1436
|
0
|
|
|
|
|
0
|
for my $oct2 (@{$range[2]}) { |
|
0
|
|
|
|
|
0
|
|
1437
|
0
|
|
|
|
|
0
|
push @chars3, pack 'CCC', $oct0,$oct1,$oct2; |
1438
|
|
|
|
|
|
|
} |
1439
|
|
|
|
|
|
|
} |
1440
|
|
|
|
|
|
|
} |
1441
|
|
|
|
|
|
|
} |
1442
|
|
|
|
|
|
|
} |
1443
|
0
|
|
|
|
|
0
|
return @chars3; |
1444
|
|
|
|
|
|
|
} |
1445
|
|
|
|
|
|
|
|
1446
|
|
|
|
|
|
|
# 4 octets characters |
1447
|
|
|
|
|
|
|
my @chars4 = (); |
1448
|
|
|
|
|
|
|
sub chars4 { |
1449
|
0
|
0
|
|
0
|
0
|
0
|
if (@chars4) { |
1450
|
0
|
|
|
|
|
0
|
return @chars4; |
1451
|
|
|
|
|
|
|
} |
1452
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{4}) { |
1453
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{4} }; |
|
0
|
|
|
|
|
0
|
|
1454
|
0
|
|
|
|
|
0
|
while (my @range = splice(@ranges,0,4)) { |
1455
|
0
|
|
|
|
|
0
|
for my $oct0 (@{$range[0]}) { |
|
0
|
|
|
|
|
0
|
|
1456
|
0
|
|
|
|
|
0
|
for my $oct1 (@{$range[1]}) { |
|
0
|
|
|
|
|
0
|
|
1457
|
0
|
|
|
|
|
0
|
for my $oct2 (@{$range[2]}) { |
|
0
|
|
|
|
|
0
|
|
1458
|
0
|
|
|
|
|
0
|
for my $oct3 (@{$range[3]}) { |
|
0
|
|
|
|
|
0
|
|
1459
|
0
|
|
|
|
|
0
|
push @chars4, pack 'CCCC', $oct0,$oct1,$oct2,$oct3; |
1460
|
|
|
|
|
|
|
} |
1461
|
|
|
|
|
|
|
} |
1462
|
|
|
|
|
|
|
} |
1463
|
|
|
|
|
|
|
} |
1464
|
|
|
|
|
|
|
} |
1465
|
|
|
|
|
|
|
} |
1466
|
0
|
|
|
|
|
0
|
return @chars4; |
1467
|
|
|
|
|
|
|
} |
1468
|
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
# |
1470
|
|
|
|
|
|
|
# HP-15 open character list for tr |
1471
|
|
|
|
|
|
|
# |
1472
|
|
|
|
|
|
|
sub _charlist_tr { |
1473
|
|
|
|
|
|
|
|
1474
|
0
|
|
|
0
|
|
0
|
local $_ = shift @_; |
1475
|
|
|
|
|
|
|
|
1476
|
|
|
|
|
|
|
# unescape character |
1477
|
0
|
|
|
|
|
0
|
my @char = (); |
1478
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxmsgc) { |
1479
|
0
|
0
|
|
|
|
0
|
if (/\G (\\0?55|\\x2[Dd]|\\-) /oxmsgc) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1480
|
0
|
|
|
|
|
0
|
push @char, '\-'; |
1481
|
|
|
|
|
|
|
} |
1482
|
|
|
|
|
|
|
elsif (/\G \\ ([0-7]{2,3}) /oxmsgc) { |
1483
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(oct $1); |
1484
|
|
|
|
|
|
|
} |
1485
|
|
|
|
|
|
|
elsif (/\G \\x ([0-9A-Fa-f]{1,2}) /oxmsgc) { |
1486
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(hex $1); |
1487
|
|
|
|
|
|
|
} |
1488
|
|
|
|
|
|
|
elsif (/\G \\c ([\x40-\x5F]) /oxmsgc) { |
1489
|
0
|
|
|
|
|
0
|
push @char, CORE::chr(CORE::ord($1) & 0x1F); |
1490
|
|
|
|
|
|
|
} |
1491
|
|
|
|
|
|
|
elsif (/\G (\\ [0nrtfbae]) /oxmsgc) { |
1492
|
|
|
|
|
|
|
push @char, { |
1493
|
|
|
|
|
|
|
'\0' => "\0", |
1494
|
|
|
|
|
|
|
'\n' => "\n", |
1495
|
|
|
|
|
|
|
'\r' => "\r", |
1496
|
|
|
|
|
|
|
'\t' => "\t", |
1497
|
|
|
|
|
|
|
'\f' => "\f", |
1498
|
|
|
|
|
|
|
'\b' => "\x08", # \b means backspace in character class |
1499
|
|
|
|
|
|
|
'\a' => "\a", |
1500
|
|
|
|
|
|
|
'\e' => "\e", |
1501
|
0
|
|
|
|
|
0
|
}->{$1}; |
1502
|
|
|
|
|
|
|
} |
1503
|
|
|
|
|
|
|
elsif (/\G \\ ($q_char) /oxmsgc) { |
1504
|
0
|
|
|
|
|
0
|
push @char, $1; |
1505
|
|
|
|
|
|
|
} |
1506
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxmsgc) { |
1507
|
0
|
|
|
|
|
0
|
push @char, $1; |
1508
|
|
|
|
|
|
|
} |
1509
|
|
|
|
|
|
|
} |
1510
|
|
|
|
|
|
|
|
1511
|
|
|
|
|
|
|
# join separated multiple-octet |
1512
|
0
|
|
|
|
|
0
|
@char = join('',@char) =~ /\G (?>\\-|$q_char) /oxmsg; |
1513
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
# unescape '-' |
1515
|
0
|
|
|
|
|
0
|
my @i = (); |
1516
|
0
|
|
|
|
|
0
|
for my $i (0 .. $#char) { |
1517
|
0
|
0
|
|
|
|
0
|
if ($char[$i] eq '\-') { |
|
|
0
|
|
|
|
|
|
1518
|
0
|
|
|
|
|
0
|
$char[$i] = '-'; |
1519
|
|
|
|
|
|
|
} |
1520
|
|
|
|
|
|
|
elsif ($char[$i] eq '-') { |
1521
|
0
|
0
|
0
|
|
|
0
|
if ((0 < $i) and ($i < $#char)) { |
1522
|
0
|
|
|
|
|
0
|
push @i, $i; |
1523
|
|
|
|
|
|
|
} |
1524
|
|
|
|
|
|
|
} |
1525
|
|
|
|
|
|
|
} |
1526
|
|
|
|
|
|
|
|
1527
|
|
|
|
|
|
|
# open character list (reverse for splice) |
1528
|
0
|
|
|
|
|
0
|
for my $i (CORE::reverse @i) { |
1529
|
0
|
|
|
|
|
0
|
my @range = (); |
1530
|
|
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
# range error |
1532
|
0
|
0
|
0
|
|
|
0
|
if ((CORE::length($char[$i-1]) > CORE::length($char[$i+1])) or ($char[$i-1] gt $char[$i+1])) { |
1533
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1534
|
|
|
|
|
|
|
} |
1535
|
|
|
|
|
|
|
|
1536
|
|
|
|
|
|
|
# range of multiple-octet code |
1537
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i-1]) == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1538
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 1) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1539
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars1(); |
|
0
|
|
|
|
|
0
|
|
1540
|
|
|
|
|
|
|
} |
1541
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 2) { |
1542
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1543
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars2(); |
|
0
|
|
|
|
|
0
|
|
1544
|
|
|
|
|
|
|
} |
1545
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 3) { |
1546
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1547
|
0
|
|
|
|
|
0
|
push @range, chars2(); |
1548
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars3(); |
|
0
|
|
|
|
|
0
|
|
1549
|
|
|
|
|
|
|
} |
1550
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1551
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars1(); |
|
0
|
|
|
|
|
0
|
|
1552
|
0
|
|
|
|
|
0
|
push @range, chars2(); |
1553
|
0
|
|
|
|
|
0
|
push @range, chars3(); |
1554
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1555
|
|
|
|
|
|
|
} |
1556
|
|
|
|
|
|
|
else { |
1557
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1558
|
|
|
|
|
|
|
} |
1559
|
|
|
|
|
|
|
} |
1560
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 2) { |
1561
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 2) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1562
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars2(); |
|
0
|
|
|
|
|
0
|
|
1563
|
|
|
|
|
|
|
} |
1564
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 3) { |
1565
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars2(); |
|
0
|
|
|
|
|
0
|
|
1566
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars3(); |
|
0
|
|
|
|
|
0
|
|
1567
|
|
|
|
|
|
|
} |
1568
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1569
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars2(); |
|
0
|
|
|
|
|
0
|
|
1570
|
0
|
|
|
|
|
0
|
push @range, chars3(); |
1571
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1572
|
|
|
|
|
|
|
} |
1573
|
|
|
|
|
|
|
else { |
1574
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1575
|
|
|
|
|
|
|
} |
1576
|
|
|
|
|
|
|
} |
1577
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 3) { |
1578
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 3) { |
|
|
0
|
|
|
|
|
|
1579
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars3(); |
|
0
|
|
|
|
|
0
|
|
1580
|
|
|
|
|
|
|
} |
1581
|
|
|
|
|
|
|
elsif (CORE::length($char[$i+1]) == 4) { |
1582
|
0
|
|
|
|
|
0
|
push @range, grep {$char[$i-1] le $_} chars3(); |
|
0
|
|
|
|
|
0
|
|
1583
|
0
|
|
|
|
|
0
|
push @range, grep {$_ le $char[$i+1]} chars4(); |
|
0
|
|
|
|
|
0
|
|
1584
|
|
|
|
|
|
|
} |
1585
|
|
|
|
|
|
|
else { |
1586
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1587
|
|
|
|
|
|
|
} |
1588
|
|
|
|
|
|
|
} |
1589
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == 4) { |
1590
|
0
|
0
|
|
|
|
0
|
if (CORE::length($char[$i+1]) == 4) { |
1591
|
0
|
0
|
|
|
|
0
|
push @range, grep {($char[$i-1] le $_) and ($_ le $char[$i+1])} chars4(); |
|
0
|
|
|
|
|
0
|
|
1592
|
|
|
|
|
|
|
} |
1593
|
|
|
|
|
|
|
else { |
1594
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1595
|
|
|
|
|
|
|
} |
1596
|
|
|
|
|
|
|
} |
1597
|
|
|
|
|
|
|
else { |
1598
|
0
|
|
|
|
|
0
|
croak "Invalid tr/// range (over 4octets) \"\\x" . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]) . '"'; |
1599
|
|
|
|
|
|
|
} |
1600
|
|
|
|
|
|
|
|
1601
|
0
|
|
|
|
|
0
|
splice @char, $i-1, 3, @range; |
1602
|
|
|
|
|
|
|
} |
1603
|
|
|
|
|
|
|
|
1604
|
0
|
|
|
|
|
0
|
return @char; |
1605
|
|
|
|
|
|
|
} |
1606
|
|
|
|
|
|
|
|
1607
|
|
|
|
|
|
|
# |
1608
|
|
|
|
|
|
|
# HP-15 open character class |
1609
|
|
|
|
|
|
|
# |
1610
|
|
|
|
|
|
|
sub _cc { |
1611
|
0
|
50
|
|
684
|
|
0
|
if (scalar(@_) == 0) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1612
|
684
|
|
|
|
|
1437
|
die __FILE__, ": subroutine cc got no parameter.\n"; |
1613
|
|
|
|
|
|
|
} |
1614
|
|
|
|
|
|
|
elsif (scalar(@_) == 1) { |
1615
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X',$_[0]); |
1616
|
|
|
|
|
|
|
} |
1617
|
|
|
|
|
|
|
elsif (scalar(@_) == 2) { |
1618
|
302
|
50
|
|
|
|
1125
|
if ($_[0] > $_[1]) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1619
|
382
|
|
|
|
|
969
|
die __FILE__, ": subroutine cc got \$_[0] > \$_[1] parameters).\n"; |
1620
|
|
|
|
|
|
|
} |
1621
|
|
|
|
|
|
|
elsif ($_[0] == $_[1]) { |
1622
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X',$_[0]); |
1623
|
|
|
|
|
|
|
} |
1624
|
|
|
|
|
|
|
elsif (($_[0]+1) == $_[1]) { |
1625
|
40
|
|
|
|
|
94
|
return sprintf('[\\x%02X\\x%02X]',$_[0],$_[1]); |
1626
|
|
|
|
|
|
|
} |
1627
|
|
|
|
|
|
|
else { |
1628
|
0
|
|
|
|
|
0
|
return sprintf('[\\x%02X-\\x%02X]',$_[0],$_[1]); |
1629
|
|
|
|
|
|
|
} |
1630
|
|
|
|
|
|
|
} |
1631
|
|
|
|
|
|
|
else { |
1632
|
342
|
|
|
|
|
1731
|
die __FILE__, ": subroutine cc got 3 or more parameters (@{[scalar(@_)]} parameters).\n"; |
|
0
|
|
|
|
|
0
|
|
1633
|
|
|
|
|
|
|
} |
1634
|
|
|
|
|
|
|
} |
1635
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
# |
1637
|
|
|
|
|
|
|
# HP-15 octet range |
1638
|
|
|
|
|
|
|
# |
1639
|
|
|
|
|
|
|
sub _octets { |
1640
|
0
|
|
|
688
|
|
0
|
my $length = shift @_; |
1641
|
|
|
|
|
|
|
|
1642
|
688
|
100
|
|
|
|
1125
|
if ($length == 1) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1643
|
688
|
|
|
|
|
1505
|
my($a1) = unpack 'C', $_[0]; |
1644
|
426
|
|
|
|
|
1126
|
my($z1) = unpack 'C', $_[1]; |
1645
|
|
|
|
|
|
|
|
1646
|
426
|
50
|
|
|
|
837
|
if ($a1 > $z1) { |
1647
|
426
|
|
|
|
|
914
|
croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$a1) . '-\x' . unpack('H*',$z1); |
1648
|
|
|
|
|
|
|
} |
1649
|
|
|
|
|
|
|
|
1650
|
0
|
100
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
50
|
|
|
|
|
|
1651
|
426
|
|
|
|
|
1026
|
return sprintf('\x%02X',$a1); |
1652
|
|
|
|
|
|
|
} |
1653
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1654
|
20
|
|
|
|
|
78
|
return sprintf('\x%02X\x%02X',$a1,$z1); |
1655
|
|
|
|
|
|
|
} |
1656
|
|
|
|
|
|
|
else { |
1657
|
0
|
|
|
|
|
0
|
return sprintf('\x%02X-\x%02X',$a1,$z1); |
1658
|
|
|
|
|
|
|
} |
1659
|
|
|
|
|
|
|
} |
1660
|
|
|
|
|
|
|
elsif ($length == 2) { |
1661
|
406
|
|
|
|
|
2636
|
my($a1,$a2) = unpack 'CC', $_[0]; |
1662
|
262
|
|
|
|
|
631
|
my($z1,$z2) = unpack 'CC', $_[1]; |
1663
|
262
|
|
|
|
|
507
|
my($A1,$A2) = unpack 'CC', $_[2]; |
1664
|
262
|
|
|
|
|
469
|
my($Z1,$Z2) = unpack 'CC', $_[3]; |
1665
|
|
|
|
|
|
|
|
1666
|
262
|
100
|
|
|
|
463
|
if ($a1 == $z1) { |
|
|
50
|
|
|
|
|
|
1667
|
|
|
|
|
|
|
return ( |
1668
|
|
|
|
|
|
|
# 11111111 222222222222 |
1669
|
|
|
|
|
|
|
# A A Z |
1670
|
262
|
|
|
|
|
475
|
_cc($a1) . _cc($a2,$z2), # a2-z2 |
1671
|
|
|
|
|
|
|
); |
1672
|
|
|
|
|
|
|
} |
1673
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1674
|
|
|
|
|
|
|
return ( |
1675
|
|
|
|
|
|
|
# 11111111111 222222222222 |
1676
|
|
|
|
|
|
|
# A Z A Z |
1677
|
222
|
|
|
|
|
425
|
_cc($a1) . _cc($a2,$Z2), # a2- |
1678
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2), # -z2 |
1679
|
|
|
|
|
|
|
); |
1680
|
|
|
|
|
|
|
} |
1681
|
|
|
|
|
|
|
else { |
1682
|
|
|
|
|
|
|
return ( |
1683
|
|
|
|
|
|
|
# 1111111111111111 222222222222 |
1684
|
|
|
|
|
|
|
# A Z A Z |
1685
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2,$Z2), # a2- |
1686
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2), # - |
1687
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2), # -z2 |
1688
|
|
|
|
|
|
|
); |
1689
|
|
|
|
|
|
|
} |
1690
|
|
|
|
|
|
|
} |
1691
|
|
|
|
|
|
|
elsif ($length == 3) { |
1692
|
40
|
|
|
|
|
65
|
my($a1,$a2,$a3) = unpack 'CCC', $_[0]; |
1693
|
0
|
|
|
|
|
0
|
my($z1,$z2,$z3) = unpack 'CCC', $_[1]; |
1694
|
0
|
|
|
|
|
0
|
my($A1,$A2,$A3) = unpack 'CCC', $_[2]; |
1695
|
0
|
|
|
|
|
0
|
my($Z1,$Z2,$Z3) = unpack 'CCC', $_[3]; |
1696
|
|
|
|
|
|
|
|
1697
|
0
|
0
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
0
|
|
|
|
|
|
1698
|
0
|
0
|
|
|
|
0
|
if ($a2 == $z2) { |
|
|
0
|
|
|
|
|
|
1699
|
|
|
|
|
|
|
return ( |
1700
|
|
|
|
|
|
|
# 11111111 22222222 333333333333 |
1701
|
|
|
|
|
|
|
# A A A Z |
1702
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$z3), # a3-z3 |
1703
|
|
|
|
|
|
|
); |
1704
|
|
|
|
|
|
|
} |
1705
|
|
|
|
|
|
|
elsif (($a2+1) == $z2) { |
1706
|
|
|
|
|
|
|
return ( |
1707
|
|
|
|
|
|
|
# 11111111 22222222222 333333333333 |
1708
|
|
|
|
|
|
|
# A A Z A Z |
1709
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1710
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1711
|
|
|
|
|
|
|
); |
1712
|
|
|
|
|
|
|
} |
1713
|
|
|
|
|
|
|
else { |
1714
|
|
|
|
|
|
|
return ( |
1715
|
|
|
|
|
|
|
# 11111111 2222222222222222 333333333333 |
1716
|
|
|
|
|
|
|
# A A Z A Z |
1717
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1718
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$z2-1) . _cc($A3,$Z3), # - |
1719
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1720
|
|
|
|
|
|
|
); |
1721
|
|
|
|
|
|
|
} |
1722
|
|
|
|
|
|
|
} |
1723
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1724
|
|
|
|
|
|
|
return ( |
1725
|
|
|
|
|
|
|
# 11111111111 22222222222222 333333333333 |
1726
|
|
|
|
|
|
|
# A Z A Z A Z |
1727
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1728
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3), # - |
1729
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3), # - |
1730
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1731
|
|
|
|
|
|
|
); |
1732
|
|
|
|
|
|
|
} |
1733
|
|
|
|
|
|
|
else { |
1734
|
|
|
|
|
|
|
return ( |
1735
|
|
|
|
|
|
|
# 1111111111111111 22222222222222 333333333333 |
1736
|
|
|
|
|
|
|
# A Z A Z A Z |
1737
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3,$Z3), # a3- |
1738
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3), # - |
1739
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2) . _cc($A3,$Z3), # - |
1740
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3), # - |
1741
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3), # -z3 |
1742
|
|
|
|
|
|
|
); |
1743
|
|
|
|
|
|
|
} |
1744
|
|
|
|
|
|
|
} |
1745
|
|
|
|
|
|
|
elsif ($length == 4) { |
1746
|
0
|
|
|
|
|
0
|
my($a1,$a2,$a3,$a4) = unpack 'CCCC', $_[0]; |
1747
|
0
|
|
|
|
|
0
|
my($z1,$z2,$z3,$z4) = unpack 'CCCC', $_[1]; |
1748
|
0
|
|
|
|
|
0
|
my($A1,$A2,$A3,$A4) = unpack 'CCCC', $_[0]; |
1749
|
0
|
|
|
|
|
0
|
my($Z1,$Z2,$Z3,$Z4) = unpack 'CCCC', $_[1]; |
1750
|
|
|
|
|
|
|
|
1751
|
0
|
0
|
|
|
|
0
|
if ($a1 == $z1) { |
|
|
0
|
|
|
|
|
|
1752
|
0
|
0
|
|
|
|
0
|
if ($a2 == $z2) { |
|
|
0
|
|
|
|
|
|
1753
|
0
|
0
|
|
|
|
0
|
if ($a3 == $z3) { |
|
|
0
|
|
|
|
|
|
1754
|
|
|
|
|
|
|
return ( |
1755
|
|
|
|
|
|
|
# 11111111 22222222 33333333 444444444444 |
1756
|
|
|
|
|
|
|
# A A A A Z |
1757
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$z4), # a4-z4 |
1758
|
|
|
|
|
|
|
); |
1759
|
|
|
|
|
|
|
} |
1760
|
|
|
|
|
|
|
elsif (($a3+1) == $z3) { |
1761
|
|
|
|
|
|
|
return ( |
1762
|
|
|
|
|
|
|
# 11111111 22222222 33333333333 444444444444 |
1763
|
|
|
|
|
|
|
# A A A Z A Z |
1764
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1765
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1766
|
|
|
|
|
|
|
); |
1767
|
|
|
|
|
|
|
} |
1768
|
|
|
|
|
|
|
else { |
1769
|
|
|
|
|
|
|
return ( |
1770
|
|
|
|
|
|
|
# 11111111 22222222 3333333333333333 444444444444 |
1771
|
|
|
|
|
|
|
# A A A Z A Z |
1772
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1773
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$z3-1) . _cc($A4,$Z4), # - |
1774
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1775
|
|
|
|
|
|
|
); |
1776
|
|
|
|
|
|
|
} |
1777
|
|
|
|
|
|
|
} |
1778
|
|
|
|
|
|
|
elsif (($a2+1) == $z2) { |
1779
|
|
|
|
|
|
|
return ( |
1780
|
|
|
|
|
|
|
# 11111111 22222222222 33333333333333 444444444444 |
1781
|
|
|
|
|
|
|
# A A Z A Z A Z |
1782
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1783
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1784
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1785
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1786
|
|
|
|
|
|
|
); |
1787
|
|
|
|
|
|
|
} |
1788
|
|
|
|
|
|
|
else { |
1789
|
|
|
|
|
|
|
return ( |
1790
|
|
|
|
|
|
|
# 11111111 2222222222222222 33333333333333 444444444444 |
1791
|
|
|
|
|
|
|
# A A Z A Z A Z |
1792
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1793
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1794
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1795
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1796
|
|
|
|
|
|
|
_cc($a1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1797
|
|
|
|
|
|
|
); |
1798
|
|
|
|
|
|
|
} |
1799
|
|
|
|
|
|
|
} |
1800
|
|
|
|
|
|
|
elsif (($a1+1) == $z1) { |
1801
|
|
|
|
|
|
|
return ( |
1802
|
|
|
|
|
|
|
# 11111111111 22222222222222 33333333333333 444444444444 |
1803
|
|
|
|
|
|
|
# A Z A Z A Z A Z |
1804
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1805
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1806
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1807
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1808
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1809
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1810
|
|
|
|
|
|
|
); |
1811
|
|
|
|
|
|
|
} |
1812
|
|
|
|
|
|
|
else { |
1813
|
|
|
|
|
|
|
return ( |
1814
|
|
|
|
|
|
|
# 1111111111111111 22222222222222 33333333333333 444444444444 |
1815
|
|
|
|
|
|
|
# A Z A Z A Z A Z |
1816
|
0
|
|
|
|
|
0
|
_cc($a1) . _cc($a2) . _cc($a3) . _cc($a4,$Z4), # a4- |
1817
|
|
|
|
|
|
|
_cc($a1) . _cc($a2) . _cc($a3+1,$Z3) . _cc($A4,$Z4), # - |
1818
|
|
|
|
|
|
|
_cc($a1) . _cc($a2+1,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1819
|
|
|
|
|
|
|
_cc($a1+1,$z1-1) . _cc($A2,$Z2) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1820
|
|
|
|
|
|
|
_cc( $z1) . _cc($A2,$z2-1) . _cc($A3,$Z3) . _cc($A4,$Z4), # - |
1821
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc($A3,$z3-1) . _cc($A4,$Z4), # - |
1822
|
|
|
|
|
|
|
_cc( $z1) . _cc( $z2) . _cc( $z3) . _cc($A4,$z4), # -z4 |
1823
|
|
|
|
|
|
|
); |
1824
|
|
|
|
|
|
|
} |
1825
|
|
|
|
|
|
|
} |
1826
|
|
|
|
|
|
|
else { |
1827
|
0
|
|
|
|
|
0
|
die __FILE__, ": subroutine _octets got invalid length ($length).\n"; |
1828
|
|
|
|
|
|
|
} |
1829
|
|
|
|
|
|
|
} |
1830
|
|
|
|
|
|
|
|
1831
|
|
|
|
|
|
|
# |
1832
|
|
|
|
|
|
|
# HP-15 range regexp |
1833
|
|
|
|
|
|
|
# |
1834
|
|
|
|
|
|
|
sub _range_regexp { |
1835
|
0
|
|
|
517
|
|
0
|
my($length,$first,$last) = @_; |
1836
|
|
|
|
|
|
|
|
1837
|
517
|
|
|
|
|
1427
|
my @range_regexp = (); |
1838
|
517
|
50
|
|
|
|
751
|
if (not exists $range_tr{$length}) { |
1839
|
517
|
|
|
|
|
1396
|
return @range_regexp; |
1840
|
|
|
|
|
|
|
} |
1841
|
|
|
|
|
|
|
|
1842
|
0
|
|
|
|
|
0
|
my @ranges = @{ $range_tr{$length} }; |
|
517
|
|
|
|
|
729
|
|
1843
|
517
|
|
|
|
|
1423
|
while (my @range = splice(@ranges,0,$length)) { |
1844
|
517
|
|
|
|
|
1686
|
my $min = ''; |
1845
|
1682
|
|
|
|
|
2616
|
my $max = ''; |
1846
|
1682
|
|
|
|
|
2022
|
for (my $i=0; $i < $length; $i++) { |
1847
|
1682
|
|
|
|
|
3090
|
$min .= pack 'C', $range[$i][0]; |
1848
|
2206
|
|
|
|
|
4406
|
$max .= pack 'C', $range[$i][-1]; |
1849
|
|
|
|
|
|
|
} |
1850
|
|
|
|
|
|
|
|
1851
|
|
|
|
|
|
|
# min___max |
1852
|
|
|
|
|
|
|
# FIRST_____________LAST |
1853
|
|
|
|
|
|
|
# (nothing) |
1854
|
|
|
|
|
|
|
|
1855
|
2206
|
50
|
66
|
|
|
4486
|
if ($max lt $first) { |
|
|
100
|
100
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
1856
|
|
|
|
|
|
|
} |
1857
|
|
|
|
|
|
|
|
1858
|
|
|
|
|
|
|
# ********** |
1859
|
|
|
|
|
|
|
# min_________max |
1860
|
|
|
|
|
|
|
# FIRST_____________LAST |
1861
|
|
|
|
|
|
|
# ********** |
1862
|
|
|
|
|
|
|
|
1863
|
|
|
|
|
|
|
elsif (($min le $first) and ($first le $max) and ($max le $last)) { |
1864
|
1682
|
|
|
|
|
14585
|
push @range_regexp, _octets($length,$first,$max,$min,$max); |
1865
|
|
|
|
|
|
|
} |
1866
|
|
|
|
|
|
|
|
1867
|
|
|
|
|
|
|
# ********************** |
1868
|
|
|
|
|
|
|
# min________________max |
1869
|
|
|
|
|
|
|
# FIRST_____________LAST |
1870
|
|
|
|
|
|
|
# ********************** |
1871
|
|
|
|
|
|
|
|
1872
|
|
|
|
|
|
|
elsif (($min eq $first) and ($max eq $last)) { |
1873
|
28
|
|
|
|
|
81
|
push @range_regexp, _octets($length,$first,$last,$min,$max); |
1874
|
|
|
|
|
|
|
} |
1875
|
|
|
|
|
|
|
|
1876
|
|
|
|
|
|
|
# ********* |
1877
|
|
|
|
|
|
|
# min___max |
1878
|
|
|
|
|
|
|
# FIRST_____________LAST |
1879
|
|
|
|
|
|
|
# ********* |
1880
|
|
|
|
|
|
|
|
1881
|
|
|
|
|
|
|
elsif (($first le $min) and ($max le $last)) { |
1882
|
0
|
|
|
|
|
0
|
push @range_regexp, _octets($length,$min,$max,$min,$max); |
1883
|
|
|
|
|
|
|
} |
1884
|
|
|
|
|
|
|
|
1885
|
|
|
|
|
|
|
# ********************** |
1886
|
|
|
|
|
|
|
# min__________________________max |
1887
|
|
|
|
|
|
|
# FIRST_____________LAST |
1888
|
|
|
|
|
|
|
# ********************** |
1889
|
|
|
|
|
|
|
|
1890
|
|
|
|
|
|
|
elsif (($min le $first) and ($last le $max)) { |
1891
|
40
|
|
|
|
|
73
|
push @range_regexp, _octets($length,$first,$last,$min,$max); |
1892
|
|
|
|
|
|
|
} |
1893
|
|
|
|
|
|
|
|
1894
|
|
|
|
|
|
|
# ********* |
1895
|
|
|
|
|
|
|
# min________max |
1896
|
|
|
|
|
|
|
# FIRST_____________LAST |
1897
|
|
|
|
|
|
|
# ********* |
1898
|
|
|
|
|
|
|
|
1899
|
|
|
|
|
|
|
elsif (($first le $min) and ($min le $last) and ($last le $max)) { |
1900
|
580
|
|
|
|
|
1381
|
push @range_regexp, _octets($length,$min,$last,$min,$max); |
1901
|
|
|
|
|
|
|
} |
1902
|
|
|
|
|
|
|
|
1903
|
|
|
|
|
|
|
# min___max |
1904
|
|
|
|
|
|
|
# FIRST_____________LAST |
1905
|
|
|
|
|
|
|
# (nothing) |
1906
|
|
|
|
|
|
|
|
1907
|
|
|
|
|
|
|
elsif ($last lt $min) { |
1908
|
|
|
|
|
|
|
} |
1909
|
|
|
|
|
|
|
|
1910
|
|
|
|
|
|
|
else { |
1911
|
40
|
|
|
|
|
72
|
die __FILE__, ": subroutine _range_regexp panic.\n"; |
1912
|
|
|
|
|
|
|
} |
1913
|
|
|
|
|
|
|
} |
1914
|
|
|
|
|
|
|
|
1915
|
0
|
|
|
|
|
0
|
return @range_regexp; |
1916
|
|
|
|
|
|
|
} |
1917
|
|
|
|
|
|
|
|
1918
|
|
|
|
|
|
|
# |
1919
|
|
|
|
|
|
|
# HP-15 open character list for qr and not qr |
1920
|
|
|
|
|
|
|
# |
1921
|
|
|
|
|
|
|
sub _charlist { |
1922
|
|
|
|
|
|
|
|
1923
|
517
|
|
|
758
|
|
1309
|
my $modifier = pop @_; |
1924
|
758
|
|
|
|
|
1281
|
my @char = @_; |
1925
|
|
|
|
|
|
|
|
1926
|
758
|
100
|
|
|
|
1695
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
1927
|
|
|
|
|
|
|
|
1928
|
|
|
|
|
|
|
# unescape character |
1929
|
758
|
|
|
|
|
1942
|
for (my $i=0; $i <= $#char; $i++) { |
1930
|
|
|
|
|
|
|
|
1931
|
|
|
|
|
|
|
# escape - to ... |
1932
|
758
|
100
|
100
|
|
|
2666
|
if ($char[$i] eq '-') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1933
|
2648
|
100
|
100
|
|
|
18698
|
if ((0 < $i) and ($i < $#char)) { |
1934
|
522
|
|
|
|
|
1951
|
$char[$i] = '...'; |
1935
|
|
|
|
|
|
|
} |
1936
|
|
|
|
|
|
|
} |
1937
|
|
|
|
|
|
|
|
1938
|
|
|
|
|
|
|
# octal escape sequence |
1939
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
1940
|
497
|
|
|
|
|
1205
|
$char[$i] = octchr($1); |
1941
|
|
|
|
|
|
|
} |
1942
|
|
|
|
|
|
|
|
1943
|
|
|
|
|
|
|
# hexadecimal escape sequence |
1944
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
1945
|
0
|
|
|
|
|
0
|
$char[$i] = hexchr($1); |
1946
|
|
|
|
|
|
|
} |
1947
|
|
|
|
|
|
|
|
1948
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
1949
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
1950
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
1951
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
1952
|
|
|
|
|
|
|
# \P{PROPERTY} --> P\{PROPERTY} |
1953
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} ) \z/oxms) { |
1954
|
0
|
|
|
|
|
0
|
$char[$i] = $1 . '\\' . $2; |
1955
|
|
|
|
|
|
|
} |
1956
|
|
|
|
|
|
|
|
1957
|
|
|
|
|
|
|
# \p, \P, \X --> p, P, X |
1958
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
1959
|
0
|
|
|
|
|
0
|
$char[$i] = $1; |
1960
|
|
|
|
|
|
|
} |
1961
|
|
|
|
|
|
|
|
1962
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([0-7]{2,3}) \z/oxms) { |
1963
|
0
|
|
|
|
|
0
|
$char[$i] = CORE::chr oct $1; |
1964
|
|
|
|
|
|
|
} |
1965
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x ([0-9A-Fa-f]{1,2}) \z/oxms) { |
1966
|
0
|
|
|
|
|
0
|
$char[$i] = CORE::chr hex $1; |
1967
|
|
|
|
|
|
|
} |
1968
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\c ([\x40-\x5F]) \z/oxms) { |
1969
|
206
|
|
|
|
|
914
|
$char[$i] = CORE::chr(CORE::ord($1) & 0x1F); |
1970
|
|
|
|
|
|
|
} |
1971
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (\\ [0nrtfbaedswDSWHVhvR]) \z/oxms) { |
1972
|
|
|
|
|
|
|
$char[$i] = { |
1973
|
|
|
|
|
|
|
'\0' => "\0", |
1974
|
|
|
|
|
|
|
'\n' => "\n", |
1975
|
|
|
|
|
|
|
'\r' => "\r", |
1976
|
|
|
|
|
|
|
'\t' => "\t", |
1977
|
|
|
|
|
|
|
'\f' => "\f", |
1978
|
|
|
|
|
|
|
'\b' => "\x08", # \b means backspace in character class |
1979
|
|
|
|
|
|
|
'\a' => "\a", |
1980
|
|
|
|
|
|
|
'\e' => "\e", |
1981
|
|
|
|
|
|
|
'\d' => '[0-9]', |
1982
|
|
|
|
|
|
|
|
1983
|
|
|
|
|
|
|
# Vertical tabs are now whitespace |
1984
|
|
|
|
|
|
|
# \s in a regex now matches a vertical tab in all circumstances. |
1985
|
|
|
|
|
|
|
# http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod#Vertical_tabs_are_now_whitespace |
1986
|
|
|
|
|
|
|
# \t \n \v \f \r space |
1987
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A \x0C\x0D\x20]', |
1988
|
|
|
|
|
|
|
# '\s' => '[\x09\x0A\x0B\x0C\x0D\x20]', |
1989
|
|
|
|
|
|
|
'\s' => '\s', |
1990
|
|
|
|
|
|
|
|
1991
|
|
|
|
|
|
|
'\w' => '[0-9A-Z_a-z]', |
1992
|
|
|
|
|
|
|
'\D' => '${Ehp15::eD}', |
1993
|
|
|
|
|
|
|
'\S' => '${Ehp15::eS}', |
1994
|
|
|
|
|
|
|
'\W' => '${Ehp15::eW}', |
1995
|
|
|
|
|
|
|
|
1996
|
|
|
|
|
|
|
'\H' => '${Ehp15::eH}', |
1997
|
|
|
|
|
|
|
'\V' => '${Ehp15::eV}', |
1998
|
|
|
|
|
|
|
'\h' => '[\x09\x20]', |
1999
|
|
|
|
|
|
|
'\v' => '[\x0A\x0B\x0C\x0D]', |
2000
|
|
|
|
|
|
|
'\R' => '${Ehp15::eR}', |
2001
|
|
|
|
|
|
|
|
2002
|
0
|
|
|
|
|
0
|
}->{$1}; |
2003
|
|
|
|
|
|
|
} |
2004
|
|
|
|
|
|
|
|
2005
|
|
|
|
|
|
|
# POSIX-style character classes |
2006
|
|
|
|
|
|
|
elsif ($ignorecase and ($char[$i] =~ /\A ( \[\: \^? (?:lower|upper) :\] ) \z/oxms)) { |
2007
|
|
|
|
|
|
|
$char[$i] = { |
2008
|
|
|
|
|
|
|
|
2009
|
|
|
|
|
|
|
'[:lower:]' => '[\x41-\x5A\x61-\x7A]', |
2010
|
|
|
|
|
|
|
'[:upper:]' => '[\x41-\x5A\x61-\x7A]', |
2011
|
|
|
|
|
|
|
'[:^lower:]' => '${Ehp15::not_lower_i}', |
2012
|
|
|
|
|
|
|
'[:^upper:]' => '${Ehp15::not_upper_i}', |
2013
|
|
|
|
|
|
|
|
2014
|
33
|
|
|
|
|
562
|
}->{$1}; |
2015
|
|
|
|
|
|
|
} |
2016
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \[\: \^? (?:alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit) :\] ) \z/oxms) { |
2017
|
|
|
|
|
|
|
$char[$i] = { |
2018
|
|
|
|
|
|
|
|
2019
|
|
|
|
|
|
|
'[:alnum:]' => '[\x30-\x39\x41-\x5A\x61-\x7A]', |
2020
|
|
|
|
|
|
|
'[:alpha:]' => '[\x41-\x5A\x61-\x7A]', |
2021
|
|
|
|
|
|
|
'[:ascii:]' => '[\x00-\x7F]', |
2022
|
|
|
|
|
|
|
'[:blank:]' => '[\x09\x20]', |
2023
|
|
|
|
|
|
|
'[:cntrl:]' => '[\x00-\x1F\x7F]', |
2024
|
|
|
|
|
|
|
'[:digit:]' => '[\x30-\x39]', |
2025
|
|
|
|
|
|
|
'[:graph:]' => '[\x21-\x7F]', |
2026
|
|
|
|
|
|
|
'[:lower:]' => '[\x61-\x7A]', |
2027
|
|
|
|
|
|
|
'[:print:]' => '[\x20-\x7F]', |
2028
|
|
|
|
|
|
|
'[:punct:]' => '[\x21-\x2F\x3A-\x3F\x40\x5B-\x5F\x60\x7B-\x7E]', |
2029
|
|
|
|
|
|
|
|
2030
|
|
|
|
|
|
|
# P.174 POSIX-Style Character Classes |
2031
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
2032
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2033
|
|
|
|
|
|
|
|
2034
|
|
|
|
|
|
|
# P.311 11.2.4 Character Classes and other Special Escapes |
2035
|
|
|
|
|
|
|
# in Chapter 11: perlre: Perl regular expressions |
2036
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
2037
|
|
|
|
|
|
|
|
2038
|
|
|
|
|
|
|
# P.210 POSIX-Style Character Classes |
2039
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
2040
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2041
|
|
|
|
|
|
|
|
2042
|
|
|
|
|
|
|
'[:space:]' => '[\s\x0B]', # "\s" plus vertical tab ("\cK") |
2043
|
|
|
|
|
|
|
|
2044
|
|
|
|
|
|
|
'[:upper:]' => '[\x41-\x5A]', |
2045
|
|
|
|
|
|
|
'[:word:]' => '[\x30-\x39\x41-\x5A\x5F\x61-\x7A]', |
2046
|
|
|
|
|
|
|
'[:xdigit:]' => '[\x30-\x39\x41-\x46\x61-\x66]', |
2047
|
|
|
|
|
|
|
'[:^alnum:]' => '${Ehp15::not_alnum}', |
2048
|
|
|
|
|
|
|
'[:^alpha:]' => '${Ehp15::not_alpha}', |
2049
|
|
|
|
|
|
|
'[:^ascii:]' => '${Ehp15::not_ascii}', |
2050
|
|
|
|
|
|
|
'[:^blank:]' => '${Ehp15::not_blank}', |
2051
|
|
|
|
|
|
|
'[:^cntrl:]' => '${Ehp15::not_cntrl}', |
2052
|
|
|
|
|
|
|
'[:^digit:]' => '${Ehp15::not_digit}', |
2053
|
|
|
|
|
|
|
'[:^graph:]' => '${Ehp15::not_graph}', |
2054
|
|
|
|
|
|
|
'[:^lower:]' => '${Ehp15::not_lower}', |
2055
|
|
|
|
|
|
|
'[:^print:]' => '${Ehp15::not_print}', |
2056
|
|
|
|
|
|
|
'[:^punct:]' => '${Ehp15::not_punct}', |
2057
|
|
|
|
|
|
|
'[:^space:]' => '${Ehp15::not_space}', |
2058
|
|
|
|
|
|
|
'[:^upper:]' => '${Ehp15::not_upper}', |
2059
|
|
|
|
|
|
|
'[:^word:]' => '${Ehp15::not_word}', |
2060
|
|
|
|
|
|
|
'[:^xdigit:]' => '${Ehp15::not_xdigit}', |
2061
|
|
|
|
|
|
|
|
2062
|
8
|
|
|
|
|
65
|
}->{$1}; |
2063
|
|
|
|
|
|
|
} |
2064
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ($q_char) \z/oxms) { |
2065
|
70
|
|
|
|
|
1652
|
$char[$i] = $1; |
2066
|
|
|
|
|
|
|
} |
2067
|
|
|
|
|
|
|
} |
2068
|
|
|
|
|
|
|
|
2069
|
|
|
|
|
|
|
# open character list |
2070
|
7
|
|
|
|
|
36
|
my @singleoctet = (); |
2071
|
758
|
|
|
|
|
1407
|
my @multipleoctet = (); |
2072
|
758
|
|
|
|
|
1128
|
for (my $i=0; $i <= $#char; ) { |
2073
|
|
|
|
|
|
|
|
2074
|
|
|
|
|
|
|
# escaped - |
2075
|
758
|
100
|
100
|
|
|
1852
|
if (defined($char[$i+1]) and ($char[$i+1] eq '...')) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2076
|
2151
|
|
|
|
|
9351
|
$i += 1; |
2077
|
497
|
|
|
|
|
680
|
next; |
2078
|
|
|
|
|
|
|
} |
2079
|
|
|
|
|
|
|
|
2080
|
|
|
|
|
|
|
# make range regexp |
2081
|
|
|
|
|
|
|
elsif ($char[$i] eq '...') { |
2082
|
|
|
|
|
|
|
|
2083
|
|
|
|
|
|
|
# range error |
2084
|
497
|
50
|
|
|
|
1017
|
if (CORE::length($char[$i-1]) > CORE::length($char[$i+1])) { |
|
|
100
|
|
|
|
|
|
2085
|
497
|
|
|
|
|
1947
|
croak 'Invalid [] range in regexp (length(A) > length(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]); |
2086
|
|
|
|
|
|
|
} |
2087
|
|
|
|
|
|
|
elsif (CORE::length($char[$i-1]) == CORE::length($char[$i+1])) { |
2088
|
0
|
50
|
|
|
|
0
|
if ($char[$i-1] gt $char[$i+1]) { |
2089
|
477
|
|
|
|
|
1173
|
croak 'Invalid [] range in regexp (CORE::ord(A) > CORE::ord(B)) ' . '\x' . unpack('H*',$char[$i-1]) . '-\x' . unpack('H*',$char[$i+1]); |
2090
|
|
|
|
|
|
|
} |
2091
|
|
|
|
|
|
|
} |
2092
|
|
|
|
|
|
|
|
2093
|
|
|
|
|
|
|
# make range regexp per length |
2094
|
0
|
|
|
|
|
0
|
for my $length (CORE::length($char[$i-1]) .. CORE::length($char[$i+1])) { |
2095
|
497
|
|
|
|
|
1512
|
my @regexp = (); |
2096
|
|
|
|
|
|
|
|
2097
|
|
|
|
|
|
|
# is first and last |
2098
|
517
|
100
|
100
|
|
|
770
|
if (($length == CORE::length($char[$i-1])) and ($length == CORE::length($char[$i+1]))) { |
|
|
100
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2099
|
517
|
|
|
|
|
1945
|
push @regexp, _range_regexp($length, $char[$i-1], $char[$i+1]); |
2100
|
|
|
|
|
|
|
} |
2101
|
|
|
|
|
|
|
|
2102
|
|
|
|
|
|
|
# is first |
2103
|
|
|
|
|
|
|
elsif ($length == CORE::length($char[$i-1])) { |
2104
|
477
|
|
|
|
|
1356
|
push @regexp, _range_regexp($length, $char[$i-1], "\xFF" x $length); |
2105
|
|
|
|
|
|
|
} |
2106
|
|
|
|
|
|
|
|
2107
|
|
|
|
|
|
|
# is inside in first and last |
2108
|
|
|
|
|
|
|
elsif ((CORE::length($char[$i-1]) < $length) and ($length < CORE::length($char[$i+1]))) { |
2109
|
20
|
|
|
|
|
76
|
push @regexp, _range_regexp($length, "\x00" x $length, "\xFF" x $length); |
2110
|
|
|
|
|
|
|
} |
2111
|
|
|
|
|
|
|
|
2112
|
|
|
|
|
|
|
# is last |
2113
|
|
|
|
|
|
|
elsif ($length == CORE::length($char[$i+1])) { |
2114
|
0
|
|
|
|
|
0
|
push @regexp, _range_regexp($length, "\x00" x $length, $char[$i+1]); |
2115
|
|
|
|
|
|
|
} |
2116
|
|
|
|
|
|
|
|
2117
|
|
|
|
|
|
|
else { |
2118
|
20
|
|
|
|
|
109
|
die __FILE__, ": subroutine make_regexp panic.\n"; |
2119
|
|
|
|
|
|
|
} |
2120
|
|
|
|
|
|
|
|
2121
|
0
|
100
|
|
|
|
0
|
if ($length == 1) { |
2122
|
517
|
|
|
|
|
1146
|
push @singleoctet, @regexp; |
2123
|
|
|
|
|
|
|
} |
2124
|
|
|
|
|
|
|
else { |
2125
|
386
|
|
|
|
|
921
|
push @multipleoctet, @regexp; |
2126
|
|
|
|
|
|
|
} |
2127
|
|
|
|
|
|
|
} |
2128
|
|
|
|
|
|
|
|
2129
|
131
|
|
|
|
|
344
|
$i += 2; |
2130
|
|
|
|
|
|
|
} |
2131
|
|
|
|
|
|
|
|
2132
|
|
|
|
|
|
|
# with /i modifier |
2133
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) { |
2134
|
497
|
100
|
|
|
|
1161
|
if ($modifier =~ /i/oxms) { |
2135
|
764
|
|
|
|
|
1378
|
my $uc = Ehp15::uc($char[$i]); |
2136
|
192
|
|
|
|
|
366
|
my $fc = Ehp15::fc($char[$i]); |
2137
|
192
|
50
|
|
|
|
379
|
if ($uc ne $fc) { |
2138
|
192
|
50
|
|
|
|
387
|
if (CORE::length($fc) == 1) { |
2139
|
192
|
|
|
|
|
303
|
push @singleoctet, $uc, $fc; |
2140
|
|
|
|
|
|
|
} |
2141
|
|
|
|
|
|
|
else { |
2142
|
192
|
|
|
|
|
409
|
push @singleoctet, $uc; |
2143
|
0
|
|
|
|
|
0
|
push @multipleoctet, $fc; |
2144
|
|
|
|
|
|
|
} |
2145
|
|
|
|
|
|
|
} |
2146
|
|
|
|
|
|
|
else { |
2147
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2148
|
|
|
|
|
|
|
} |
2149
|
|
|
|
|
|
|
} |
2150
|
|
|
|
|
|
|
else { |
2151
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2152
|
|
|
|
|
|
|
} |
2153
|
572
|
|
|
|
|
902
|
$i += 1; |
2154
|
|
|
|
|
|
|
} |
2155
|
|
|
|
|
|
|
|
2156
|
|
|
|
|
|
|
# single character of single octet code |
2157
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\h ) \z/oxms) { |
2158
|
764
|
|
|
|
|
1343
|
push @singleoctet, "\t", "\x20"; |
2159
|
0
|
|
|
|
|
0
|
$i += 1; |
2160
|
|
|
|
|
|
|
} |
2161
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\v ) \z/oxms) { |
2162
|
0
|
|
|
|
|
0
|
push @singleoctet, "\x0A", "\x0B", "\x0C", "\x0D"; |
2163
|
0
|
|
|
|
|
0
|
$i += 1; |
2164
|
|
|
|
|
|
|
} |
2165
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A (?: \\d | \\s | \\w ) \z/oxms) { |
2166
|
0
|
|
|
|
|
0
|
push @singleoctet, $char[$i]; |
2167
|
2
|
|
|
|
|
7
|
$i += 1; |
2168
|
|
|
|
|
|
|
} |
2169
|
|
|
|
|
|
|
|
2170
|
|
|
|
|
|
|
# single character of multiple-octet code |
2171
|
|
|
|
|
|
|
else { |
2172
|
2
|
|
|
|
|
5
|
push @multipleoctet, $char[$i]; |
2173
|
391
|
|
|
|
|
838
|
$i += 1; |
2174
|
|
|
|
|
|
|
} |
2175
|
|
|
|
|
|
|
} |
2176
|
|
|
|
|
|
|
|
2177
|
|
|
|
|
|
|
# quote metachar |
2178
|
391
|
|
|
|
|
793
|
for (@singleoctet) { |
2179
|
758
|
50
|
|
|
|
1557
|
if ($_ eq '...') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2180
|
1384
|
|
|
|
|
6358
|
$_ = '-'; |
2181
|
|
|
|
|
|
|
} |
2182
|
|
|
|
|
|
|
elsif (/\A \n \z/oxms) { |
2183
|
0
|
|
|
|
|
0
|
$_ = '\n'; |
2184
|
|
|
|
|
|
|
} |
2185
|
|
|
|
|
|
|
elsif (/\A \r \z/oxms) { |
2186
|
8
|
|
|
|
|
20
|
$_ = '\r'; |
2187
|
|
|
|
|
|
|
} |
2188
|
|
|
|
|
|
|
elsif (/\A ([\x00-\x20\x7F-\xFF]) \z/oxms) { |
2189
|
8
|
|
|
|
|
21
|
$_ = sprintf('\x%02X', CORE::ord $1); |
2190
|
|
|
|
|
|
|
} |
2191
|
|
|
|
|
|
|
elsif (/\A [\x00-\xFF] \z/oxms) { |
2192
|
1
|
|
|
|
|
6
|
$_ = quotemeta $_; |
2193
|
|
|
|
|
|
|
} |
2194
|
|
|
|
|
|
|
} |
2195
|
939
|
|
|
|
|
1606
|
for (@multipleoctet) { |
2196
|
758
|
100
|
|
|
|
1505
|
if (/\A ([\x80-\xFF].*) ([\x00-\xFF]) \z/oxms) { |
2197
|
733
|
|
|
|
|
2029
|
$_ = $1 . quotemeta $2; |
2198
|
|
|
|
|
|
|
} |
2199
|
|
|
|
|
|
|
} |
2200
|
|
|
|
|
|
|
|
2201
|
|
|
|
|
|
|
# return character list |
2202
|
307
|
|
|
|
|
814
|
return \@singleoctet, \@multipleoctet; |
2203
|
|
|
|
|
|
|
} |
2204
|
|
|
|
|
|
|
|
2205
|
|
|
|
|
|
|
# |
2206
|
|
|
|
|
|
|
# HP-15 octal escape sequence |
2207
|
|
|
|
|
|
|
# |
2208
|
|
|
|
|
|
|
sub octchr { |
2209
|
758
|
|
|
5
|
0
|
2827
|
my($octdigit) = @_; |
2210
|
|
|
|
|
|
|
|
2211
|
5
|
|
|
|
|
13
|
my @binary = (); |
2212
|
5
|
|
|
|
|
10
|
for my $octal (split(//,$octdigit)) { |
2213
|
|
|
|
|
|
|
push @binary, { |
2214
|
|
|
|
|
|
|
'0' => '000', |
2215
|
|
|
|
|
|
|
'1' => '001', |
2216
|
|
|
|
|
|
|
'2' => '010', |
2217
|
|
|
|
|
|
|
'3' => '011', |
2218
|
|
|
|
|
|
|
'4' => '100', |
2219
|
|
|
|
|
|
|
'5' => '101', |
2220
|
|
|
|
|
|
|
'6' => '110', |
2221
|
|
|
|
|
|
|
'7' => '111', |
2222
|
5
|
|
|
|
|
22
|
}->{$octal}; |
2223
|
|
|
|
|
|
|
} |
2224
|
50
|
|
|
|
|
169
|
my $binary = join '', @binary; |
2225
|
|
|
|
|
|
|
|
2226
|
|
|
|
|
|
|
my $octchr = { |
2227
|
|
|
|
|
|
|
# 1234567 |
2228
|
|
|
|
|
|
|
1 => pack('B*', "0000000$binary"), |
2229
|
|
|
|
|
|
|
2 => pack('B*', "000000$binary"), |
2230
|
|
|
|
|
|
|
3 => pack('B*', "00000$binary"), |
2231
|
|
|
|
|
|
|
4 => pack('B*', "0000$binary"), |
2232
|
|
|
|
|
|
|
5 => pack('B*', "000$binary"), |
2233
|
|
|
|
|
|
|
6 => pack('B*', "00$binary"), |
2234
|
|
|
|
|
|
|
7 => pack('B*', "0$binary"), |
2235
|
|
|
|
|
|
|
0 => pack('B*', "$binary"), |
2236
|
|
|
|
|
|
|
|
2237
|
5
|
|
|
|
|
14
|
}->{CORE::length($binary) % 8}; |
2238
|
|
|
|
|
|
|
|
2239
|
5
|
|
|
|
|
62
|
return $octchr; |
2240
|
|
|
|
|
|
|
} |
2241
|
|
|
|
|
|
|
|
2242
|
|
|
|
|
|
|
# |
2243
|
|
|
|
|
|
|
# HP-15 hexadecimal escape sequence |
2244
|
|
|
|
|
|
|
# |
2245
|
|
|
|
|
|
|
sub hexchr { |
2246
|
5
|
|
|
5
|
0
|
20
|
my($hexdigit) = @_; |
2247
|
|
|
|
|
|
|
|
2248
|
|
|
|
|
|
|
my $hexchr = { |
2249
|
|
|
|
|
|
|
1 => pack('H*', "0$hexdigit"), |
2250
|
|
|
|
|
|
|
0 => pack('H*', "$hexdigit"), |
2251
|
|
|
|
|
|
|
|
2252
|
5
|
|
|
|
|
14
|
}->{CORE::length($_[0]) % 2}; |
2253
|
|
|
|
|
|
|
|
2254
|
5
|
|
|
|
|
39
|
return $hexchr; |
2255
|
|
|
|
|
|
|
} |
2256
|
|
|
|
|
|
|
|
2257
|
|
|
|
|
|
|
# |
2258
|
|
|
|
|
|
|
# HP-15 open character list for qr |
2259
|
|
|
|
|
|
|
# |
2260
|
|
|
|
|
|
|
sub charlist_qr { |
2261
|
|
|
|
|
|
|
|
2262
|
5
|
|
|
519
|
0
|
15
|
my $modifier = pop @_; |
2263
|
519
|
|
|
|
|
1064
|
my @char = @_; |
2264
|
|
|
|
|
|
|
|
2265
|
519
|
|
|
|
|
1385
|
my($singleoctet, $multipleoctet) = _charlist(@char, $modifier); |
2266
|
519
|
|
|
|
|
1568
|
my @singleoctet = @$singleoctet; |
2267
|
519
|
|
|
|
|
1146
|
my @multipleoctet = @$multipleoctet; |
2268
|
|
|
|
|
|
|
|
2269
|
|
|
|
|
|
|
# return character list |
2270
|
519
|
100
|
|
|
|
949
|
if (scalar(@singleoctet) >= 1) { |
2271
|
|
|
|
|
|
|
|
2272
|
|
|
|
|
|
|
# with /i modifier |
2273
|
519
|
100
|
|
|
|
1246
|
if ($modifier =~ m/i/oxms) { |
2274
|
384
|
|
|
|
|
958
|
my %singleoctet_ignorecase = (); |
2275
|
107
|
|
|
|
|
179
|
for (@singleoctet) { |
2276
|
107
|
|
100
|
|
|
168
|
while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) { |
2277
|
277
|
|
|
|
|
1040
|
for my $ord (hex($1) .. hex($2)) { |
2278
|
85
|
|
|
|
|
332
|
my $char = CORE::chr($ord); |
2279
|
1356
|
|
|
|
|
1887
|
my $uc = Ehp15::uc($char); |
2280
|
1356
|
|
|
|
|
1836
|
my $fc = Ehp15::fc($char); |
2281
|
1356
|
100
|
|
|
|
2095
|
if ($uc eq $fc) { |
2282
|
1356
|
|
|
|
|
2160
|
$singleoctet_ignorecase{unpack 'C*', $char} = 1; |
2283
|
|
|
|
|
|
|
} |
2284
|
|
|
|
|
|
|
else { |
2285
|
767
|
50
|
|
|
|
1846
|
if (CORE::length($fc) == 1) { |
2286
|
589
|
|
|
|
|
867
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2287
|
589
|
|
|
|
|
1244
|
$singleoctet_ignorecase{unpack 'C*', $fc} = 1; |
2288
|
|
|
|
|
|
|
} |
2289
|
|
|
|
|
|
|
else { |
2290
|
589
|
|
|
|
|
1540
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2291
|
0
|
|
|
|
|
0
|
push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc; |
|
0
|
|
|
|
|
0
|
|
2292
|
|
|
|
|
|
|
} |
2293
|
|
|
|
|
|
|
} |
2294
|
|
|
|
|
|
|
} |
2295
|
|
|
|
|
|
|
} |
2296
|
0
|
100
|
|
|
|
0
|
if ($_ ne '') { |
2297
|
277
|
|
|
|
|
526
|
$singleoctet_ignorecase{unpack 'C*', $_} = 1; |
2298
|
|
|
|
|
|
|
} |
2299
|
|
|
|
|
|
|
} |
2300
|
192
|
|
|
|
|
528
|
my $i = 0; |
2301
|
107
|
|
|
|
|
150
|
my @singleoctet_ignorecase = (); |
2302
|
107
|
|
|
|
|
174
|
for my $ord (0 .. 255) { |
2303
|
107
|
100
|
|
|
|
184
|
if (exists $singleoctet_ignorecase{$ord}) { |
2304
|
27392
|
|
|
|
|
36636
|
push @{$singleoctet_ignorecase[$i]}, $ord; |
|
1887
|
|
|
|
|
1875
|
|
2305
|
|
|
|
|
|
|
} |
2306
|
|
|
|
|
|
|
else { |
2307
|
1887
|
|
|
|
|
3317
|
$i++; |
2308
|
|
|
|
|
|
|
} |
2309
|
|
|
|
|
|
|
} |
2310
|
25505
|
|
|
|
|
30036
|
@singleoctet = (); |
2311
|
107
|
|
|
|
|
198
|
for my $range (@singleoctet_ignorecase) { |
2312
|
107
|
100
|
|
|
|
303
|
if (ref $range) { |
2313
|
11102
|
100
|
|
|
|
22436
|
if (scalar(@{$range}) == 1) { |
|
219
|
50
|
|
|
|
263
|
|
2314
|
219
|
|
|
|
|
376
|
push @singleoctet, sprintf('\x%02X', @{$range}[0]); |
|
5
|
|
|
|
|
6
|
|
2315
|
|
|
|
|
|
|
} |
2316
|
5
|
|
|
|
|
86
|
elsif (scalar(@{$range}) == 2) { |
2317
|
214
|
|
|
|
|
405
|
push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2318
|
|
|
|
|
|
|
} |
2319
|
|
|
|
|
|
|
else { |
2320
|
0
|
|
|
|
|
0
|
push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]); |
|
214
|
|
|
|
|
291
|
|
|
214
|
|
|
|
|
355
|
|
2321
|
|
|
|
|
|
|
} |
2322
|
|
|
|
|
|
|
} |
2323
|
|
|
|
|
|
|
} |
2324
|
|
|
|
|
|
|
} |
2325
|
|
|
|
|
|
|
|
2326
|
214
|
|
|
|
|
1081
|
my $not_anchor = ''; |
2327
|
384
|
|
|
|
|
617
|
$not_anchor = '(?![\x80-\xA0\xE0-\xFE])'; |
2328
|
|
|
|
|
|
|
|
2329
|
384
|
|
|
|
|
709
|
push @multipleoctet, join('', $not_anchor, '[', @singleoctet, ']' ); |
2330
|
|
|
|
|
|
|
} |
2331
|
384
|
100
|
|
|
|
1334
|
if (scalar(@multipleoctet) >= 2) { |
2332
|
519
|
|
|
|
|
1595
|
return '(?:' . join('|', @multipleoctet) . ')'; |
2333
|
|
|
|
|
|
|
} |
2334
|
|
|
|
|
|
|
else { |
2335
|
131
|
|
|
|
|
866
|
return $multipleoctet[0]; |
2336
|
|
|
|
|
|
|
} |
2337
|
|
|
|
|
|
|
} |
2338
|
|
|
|
|
|
|
|
2339
|
|
|
|
|
|
|
# |
2340
|
|
|
|
|
|
|
# HP-15 open character list for not qr |
2341
|
|
|
|
|
|
|
# |
2342
|
|
|
|
|
|
|
sub charlist_not_qr { |
2343
|
|
|
|
|
|
|
|
2344
|
388
|
|
|
239
|
0
|
1813
|
my $modifier = pop @_; |
2345
|
239
|
|
|
|
|
460
|
my @char = @_; |
2346
|
|
|
|
|
|
|
|
2347
|
239
|
|
|
|
|
632
|
my($singleoctet, $multipleoctet) = _charlist(@char, $modifier); |
2348
|
239
|
|
|
|
|
600
|
my @singleoctet = @$singleoctet; |
2349
|
239
|
|
|
|
|
547
|
my @multipleoctet = @$multipleoctet; |
2350
|
|
|
|
|
|
|
|
2351
|
|
|
|
|
|
|
# with /i modifier |
2352
|
239
|
100
|
|
|
|
441
|
if ($modifier =~ m/i/oxms) { |
2353
|
239
|
|
|
|
|
610
|
my %singleoctet_ignorecase = (); |
2354
|
128
|
|
|
|
|
213
|
for (@singleoctet) { |
2355
|
128
|
|
100
|
|
|
215
|
while (s/ \A \\x(..) - \\x(..) //oxms or s/ \A \\x((..)) //oxms) { |
2356
|
277
|
|
|
|
|
1055
|
for my $ord (hex($1) .. hex($2)) { |
2357
|
85
|
|
|
|
|
338
|
my $char = CORE::chr($ord); |
2358
|
1356
|
|
|
|
|
1938
|
my $uc = Ehp15::uc($char); |
2359
|
1356
|
|
|
|
|
1801
|
my $fc = Ehp15::fc($char); |
2360
|
1356
|
100
|
|
|
|
2091
|
if ($uc eq $fc) { |
2361
|
1356
|
|
|
|
|
2215
|
$singleoctet_ignorecase{unpack 'C*', $char} = 1; |
2362
|
|
|
|
|
|
|
} |
2363
|
|
|
|
|
|
|
else { |
2364
|
767
|
50
|
|
|
|
1917
|
if (CORE::length($fc) == 1) { |
2365
|
589
|
|
|
|
|
817
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2366
|
589
|
|
|
|
|
1321
|
$singleoctet_ignorecase{unpack 'C*', $fc} = 1; |
2367
|
|
|
|
|
|
|
} |
2368
|
|
|
|
|
|
|
else { |
2369
|
589
|
|
|
|
|
1506
|
$singleoctet_ignorecase{unpack 'C*', $uc} = 1; |
2370
|
0
|
|
|
|
|
0
|
push @multipleoctet, join '', map {sprintf('\x%02X',$_)} unpack 'C*', $fc; |
|
0
|
|
|
|
|
0
|
|
2371
|
|
|
|
|
|
|
} |
2372
|
|
|
|
|
|
|
} |
2373
|
|
|
|
|
|
|
} |
2374
|
|
|
|
|
|
|
} |
2375
|
0
|
100
|
|
|
|
0
|
if ($_ ne '') { |
2376
|
277
|
|
|
|
|
515
|
$singleoctet_ignorecase{unpack 'C*', $_} = 1; |
2377
|
|
|
|
|
|
|
} |
2378
|
|
|
|
|
|
|
} |
2379
|
192
|
|
|
|
|
510
|
my $i = 0; |
2380
|
128
|
|
|
|
|
189
|
my @singleoctet_ignorecase = (); |
2381
|
128
|
|
|
|
|
190
|
for my $ord (0 .. 255) { |
2382
|
128
|
100
|
|
|
|
219
|
if (exists $singleoctet_ignorecase{$ord}) { |
2383
|
32768
|
|
|
|
|
43773
|
push @{$singleoctet_ignorecase[$i]}, $ord; |
|
1887
|
|
|
|
|
1910
|
|
2384
|
|
|
|
|
|
|
} |
2385
|
|
|
|
|
|
|
else { |
2386
|
1887
|
|
|
|
|
3280
|
$i++; |
2387
|
|
|
|
|
|
|
} |
2388
|
|
|
|
|
|
|
} |
2389
|
30881
|
|
|
|
|
36574
|
@singleoctet = (); |
2390
|
128
|
|
|
|
|
216
|
for my $range (@singleoctet_ignorecase) { |
2391
|
128
|
100
|
|
|
|
313
|
if (ref $range) { |
2392
|
11102
|
100
|
|
|
|
21822
|
if (scalar(@{$range}) == 1) { |
|
219
|
50
|
|
|
|
265
|
|
2393
|
219
|
|
|
|
|
409
|
push @singleoctet, sprintf('\x%02X', @{$range}[0]); |
|
5
|
|
|
|
|
8
|
|
2394
|
|
|
|
|
|
|
} |
2395
|
5
|
|
|
|
|
93
|
elsif (scalar(@{$range}) == 2) { |
2396
|
214
|
|
|
|
|
364
|
push @singleoctet, sprintf('\x%02X\x%02X', @{$range}[0], @{$range}[-1]); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2397
|
|
|
|
|
|
|
} |
2398
|
|
|
|
|
|
|
else { |
2399
|
0
|
|
|
|
|
0
|
push @singleoctet, sprintf('\x%02X-\x%02X', @{$range}[0], @{$range}[-1]); |
|
214
|
|
|
|
|
355
|
|
|
214
|
|
|
|
|
318
|
|
2400
|
|
|
|
|
|
|
} |
2401
|
|
|
|
|
|
|
} |
2402
|
|
|
|
|
|
|
} |
2403
|
|
|
|
|
|
|
} |
2404
|
|
|
|
|
|
|
|
2405
|
|
|
|
|
|
|
# return character list |
2406
|
214
|
100
|
|
|
|
1147
|
if (scalar(@multipleoctet) >= 1) { |
2407
|
239
|
100
|
|
|
|
575
|
if (scalar(@singleoctet) >= 1) { |
2408
|
|
|
|
|
|
|
|
2409
|
|
|
|
|
|
|
# any character other than multiple-octet and single octet character class |
2410
|
114
|
|
|
|
|
237
|
return '(?!' . join('|', @multipleoctet) . ')(?:[^\x80-\xA0\xE0-\xFE' . join('', @singleoctet) . ']|[\x80-\xA0\xE0-\xFE][\x00-\xFF])'; |
2411
|
|
|
|
|
|
|
} |
2412
|
|
|
|
|
|
|
else { |
2413
|
|
|
|
|
|
|
|
2414
|
|
|
|
|
|
|
# any character other than multiple-octet character class |
2415
|
70
|
|
|
|
|
548
|
return '(?!' . join('|', @multipleoctet) . ")(?:$your_char)"; |
2416
|
|
|
|
|
|
|
} |
2417
|
|
|
|
|
|
|
} |
2418
|
|
|
|
|
|
|
else { |
2419
|
44
|
50
|
|
|
|
293
|
if (scalar(@singleoctet) >= 1) { |
2420
|
|
|
|
|
|
|
|
2421
|
|
|
|
|
|
|
# any character other than single octet character class |
2422
|
125
|
|
|
|
|
322
|
return '(?:[^\x80-\xA0\xE0-\xFE' . join('', @singleoctet) . ']|[\x80-\xA0\xE0-\xFE][\x00-\xFF])'; |
2423
|
|
|
|
|
|
|
} |
2424
|
|
|
|
|
|
|
else { |
2425
|
|
|
|
|
|
|
|
2426
|
|
|
|
|
|
|
# any character |
2427
|
125
|
|
|
|
|
801
|
return "(?:$your_char)"; |
2428
|
|
|
|
|
|
|
} |
2429
|
|
|
|
|
|
|
} |
2430
|
|
|
|
|
|
|
} |
2431
|
|
|
|
|
|
|
|
2432
|
|
|
|
|
|
|
# |
2433
|
|
|
|
|
|
|
# open file in read mode |
2434
|
|
|
|
|
|
|
# |
2435
|
|
|
|
|
|
|
sub _open_r { |
2436
|
0
|
|
|
768
|
|
0
|
my(undef,$file) = @_; |
2437
|
389
|
|
|
389
|
|
6590
|
use Fcntl qw(O_RDONLY); |
|
389
|
|
|
|
|
2317
|
|
|
389
|
|
|
|
|
63461
|
|
2438
|
768
|
|
|
|
|
2223
|
return CORE::sysopen($_[0], $file, &O_RDONLY); |
2439
|
|
|
|
|
|
|
} |
2440
|
|
|
|
|
|
|
|
2441
|
|
|
|
|
|
|
# |
2442
|
|
|
|
|
|
|
# open file in append mode |
2443
|
|
|
|
|
|
|
# |
2444
|
|
|
|
|
|
|
sub _open_a { |
2445
|
768
|
|
|
384
|
|
36402
|
my(undef,$file) = @_; |
2446
|
389
|
|
|
389
|
|
17878
|
use Fcntl qw(O_WRONLY O_APPEND O_CREAT); |
|
389
|
|
|
|
|
936
|
|
|
389
|
|
|
|
|
6150589
|
|
2447
|
384
|
|
|
|
|
1130
|
return CORE::sysopen($_[0], $file, &O_WRONLY|&O_APPEND|&O_CREAT); |
2448
|
|
|
|
|
|
|
} |
2449
|
|
|
|
|
|
|
|
2450
|
|
|
|
|
|
|
# |
2451
|
|
|
|
|
|
|
# safe system |
2452
|
|
|
|
|
|
|
# |
2453
|
|
|
|
|
|
|
sub _systemx { |
2454
|
|
|
|
|
|
|
|
2455
|
|
|
|
|
|
|
# P.707 29.2.33. exec |
2456
|
|
|
|
|
|
|
# in Chapter 29: Functions |
2457
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2458
|
|
|
|
|
|
|
# |
2459
|
|
|
|
|
|
|
# Be aware that in older releases of Perl, exec (and system) did not flush |
2460
|
|
|
|
|
|
|
# your output buffer, so you needed to enable command buffering by setting $| |
2461
|
|
|
|
|
|
|
# on one or more filehandles to avoid lost output in the case of exec, or |
2462
|
|
|
|
|
|
|
# misordererd output in the case of system. This situation was largely remedied |
2463
|
|
|
|
|
|
|
# in the 5.6 release of Perl. (So, 5.005 release not yet.) |
2464
|
|
|
|
|
|
|
|
2465
|
|
|
|
|
|
|
# P.855 exec |
2466
|
|
|
|
|
|
|
# in Chapter 27: Functions |
2467
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2468
|
|
|
|
|
|
|
# |
2469
|
|
|
|
|
|
|
# In very old release of Perl (before v5.6), exec (and system) did not flush |
2470
|
|
|
|
|
|
|
# your output buffer, so you needed to enable command buffering by setting $| |
2471
|
|
|
|
|
|
|
# on one or more filehandles to avoid lost output with exec or misordered |
2472
|
|
|
|
|
|
|
# output with system. |
2473
|
|
|
|
|
|
|
|
2474
|
384
|
|
|
384
|
|
71740
|
$| = 1; |
2475
|
|
|
|
|
|
|
|
2476
|
|
|
|
|
|
|
# P.565 23.1.2. Cleaning Up Your Environment |
2477
|
|
|
|
|
|
|
# in Chapter 23: Security |
2478
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2479
|
|
|
|
|
|
|
|
2480
|
|
|
|
|
|
|
# P.656 Cleaning Up Your Environment |
2481
|
|
|
|
|
|
|
# in Chapter 20: Security |
2482
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2483
|
|
|
|
|
|
|
|
2484
|
|
|
|
|
|
|
# local $ENV{'PATH'} = '.'; |
2485
|
384
|
|
|
|
|
1529
|
local @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer |
2486
|
|
|
|
|
|
|
|
2487
|
|
|
|
|
|
|
# P.707 29.2.33. exec |
2488
|
|
|
|
|
|
|
# in Chapter 29: Functions |
2489
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2490
|
|
|
|
|
|
|
# |
2491
|
|
|
|
|
|
|
# As we mentioned earlier, exec treats a discrete list of arguments as an |
2492
|
|
|
|
|
|
|
# indication that it should bypass shell processing. However, there is one |
2493
|
|
|
|
|
|
|
# place where you might still get tripped up. The exec call (and system, too) |
2494
|
|
|
|
|
|
|
# will not distinguish between a single scalar argument and an array containing |
2495
|
|
|
|
|
|
|
# only one element. |
2496
|
|
|
|
|
|
|
# |
2497
|
|
|
|
|
|
|
# @args = ("echo surprise"); # just one element in list |
2498
|
|
|
|
|
|
|
# exec @args # still subject to shell escapes |
2499
|
|
|
|
|
|
|
# or die "exec: $!"; # because @args == 1 |
2500
|
|
|
|
|
|
|
# |
2501
|
|
|
|
|
|
|
# To avoid this, you can use the PATHNAME syntax, explicitly duplicating the |
2502
|
|
|
|
|
|
|
# first argument as the pathname, which forces the rest of the arguments to be |
2503
|
|
|
|
|
|
|
# interpreted as a list, even if there is only one of them: |
2504
|
|
|
|
|
|
|
# |
2505
|
|
|
|
|
|
|
# exec { $args[0] } @args # safe even with one-argument list |
2506
|
|
|
|
|
|
|
# or die "can't exec @args: $!"; |
2507
|
|
|
|
|
|
|
|
2508
|
|
|
|
|
|
|
# P.855 exec |
2509
|
|
|
|
|
|
|
# in Chapter 27: Functions |
2510
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2511
|
|
|
|
|
|
|
# |
2512
|
|
|
|
|
|
|
# As we mentioned earlier, exec treats a discrete list of arguments as a |
2513
|
|
|
|
|
|
|
# directive to bypass shell processing. However, there is one place where |
2514
|
|
|
|
|
|
|
# you might still get tripped up. The exec call (and system, too) cannot |
2515
|
|
|
|
|
|
|
# distinguish between a single scalar argument and an array containing |
2516
|
|
|
|
|
|
|
# only one element. |
2517
|
|
|
|
|
|
|
# |
2518
|
|
|
|
|
|
|
# @args = ("echo surprise"); # just one element in list |
2519
|
|
|
|
|
|
|
# exec @args # still subject to shell escapes |
2520
|
|
|
|
|
|
|
# || die "exec: $!"; # because @args == 1 |
2521
|
|
|
|
|
|
|
# |
2522
|
|
|
|
|
|
|
# To avoid this, use the PATHNAME syntax, explicitly duplicating the first |
2523
|
|
|
|
|
|
|
# argument as the pathname, which forces the rest of the arguments to be |
2524
|
|
|
|
|
|
|
# interpreted as a list, even if there is only one of them: |
2525
|
|
|
|
|
|
|
# |
2526
|
|
|
|
|
|
|
# exec { $args[0] } @args # safe even with one-argument list |
2527
|
|
|
|
|
|
|
# || die "can't exec @args: $!"; |
2528
|
|
|
|
|
|
|
|
2529
|
384
|
|
|
|
|
3778
|
return CORE::system { $_[0] } @_; # safe even with one-argument list |
|
384
|
|
|
|
|
915
|
|
2530
|
|
|
|
|
|
|
} |
2531
|
|
|
|
|
|
|
|
2532
|
|
|
|
|
|
|
# |
2533
|
|
|
|
|
|
|
# HP-15 order to character (with parameter) |
2534
|
|
|
|
|
|
|
# |
2535
|
|
|
|
|
|
|
sub Ehp15::chr(;$) { |
2536
|
|
|
|
|
|
|
|
2537
|
384
|
0
|
|
0
|
0
|
49660629
|
my $c = @_ ? $_[0] : $_; |
2538
|
|
|
|
|
|
|
|
2539
|
0
|
0
|
|
|
|
0
|
if ($c == 0x00) { |
2540
|
0
|
|
|
|
|
0
|
return "\x00"; |
2541
|
|
|
|
|
|
|
} |
2542
|
|
|
|
|
|
|
else { |
2543
|
0
|
|
|
|
|
0
|
my @chr = (); |
2544
|
0
|
|
|
|
|
0
|
while ($c > 0) { |
2545
|
0
|
|
|
|
|
0
|
unshift @chr, ($c % 0x100); |
2546
|
0
|
|
|
|
|
0
|
$c = int($c / 0x100); |
2547
|
|
|
|
|
|
|
} |
2548
|
0
|
|
|
|
|
0
|
return pack 'C*', @chr; |
2549
|
|
|
|
|
|
|
} |
2550
|
|
|
|
|
|
|
} |
2551
|
|
|
|
|
|
|
|
2552
|
|
|
|
|
|
|
# |
2553
|
|
|
|
|
|
|
# HP-15 order to character (without parameter) |
2554
|
|
|
|
|
|
|
# |
2555
|
|
|
|
|
|
|
sub Ehp15::chr_() { |
2556
|
|
|
|
|
|
|
|
2557
|
0
|
|
|
0
|
0
|
0
|
my $c = $_; |
2558
|
|
|
|
|
|
|
|
2559
|
0
|
0
|
|
|
|
0
|
if ($c == 0x00) { |
2560
|
0
|
|
|
|
|
0
|
return "\x00"; |
2561
|
|
|
|
|
|
|
} |
2562
|
|
|
|
|
|
|
else { |
2563
|
0
|
|
|
|
|
0
|
my @chr = (); |
2564
|
0
|
|
|
|
|
0
|
while ($c > 0) { |
2565
|
0
|
|
|
|
|
0
|
unshift @chr, ($c % 0x100); |
2566
|
0
|
|
|
|
|
0
|
$c = int($c / 0x100); |
2567
|
|
|
|
|
|
|
} |
2568
|
0
|
|
|
|
|
0
|
return pack 'C*', @chr; |
2569
|
|
|
|
|
|
|
} |
2570
|
|
|
|
|
|
|
} |
2571
|
|
|
|
|
|
|
|
2572
|
|
|
|
|
|
|
# |
2573
|
|
|
|
|
|
|
# HP-15 stacked file test expr |
2574
|
|
|
|
|
|
|
# |
2575
|
|
|
|
|
|
|
sub Ehp15::filetest { |
2576
|
|
|
|
|
|
|
|
2577
|
0
|
|
|
0
|
0
|
0
|
my $file = pop @_; |
2578
|
0
|
|
|
|
|
0
|
my $filetest = substr(pop @_, 1); |
2579
|
|
|
|
|
|
|
|
2580
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{Ehp15::$filetest(\$file)}) { |
2581
|
0
|
|
|
|
|
0
|
return ''; |
2582
|
|
|
|
|
|
|
} |
2583
|
0
|
|
|
|
|
0
|
for my $filetest (CORE::reverse @_) { |
2584
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{ $filetest _ }) { |
2585
|
0
|
|
|
|
|
0
|
return ''; |
2586
|
|
|
|
|
|
|
} |
2587
|
|
|
|
|
|
|
} |
2588
|
0
|
|
|
|
|
0
|
return 1; |
2589
|
|
|
|
|
|
|
} |
2590
|
|
|
|
|
|
|
|
2591
|
|
|
|
|
|
|
# |
2592
|
|
|
|
|
|
|
# HP-15 file test -r expr |
2593
|
|
|
|
|
|
|
# |
2594
|
|
|
|
|
|
|
sub Ehp15::r(;*@) { |
2595
|
|
|
|
|
|
|
|
2596
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2597
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -r (Ehp15::r)' if @_ and not wantarray; |
2598
|
|
|
|
|
|
|
|
2599
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2600
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2601
|
|
|
|
|
|
|
} |
2602
|
|
|
|
|
|
|
|
2603
|
|
|
|
|
|
|
# P.908 32.39. Symbol |
2604
|
|
|
|
|
|
|
# in Chapter 32: Standard Modules |
2605
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
2606
|
|
|
|
|
|
|
|
2607
|
|
|
|
|
|
|
# P.326 Prototypes |
2608
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
2609
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
2610
|
|
|
|
|
|
|
|
2611
|
|
|
|
|
|
|
# (and so on) |
2612
|
|
|
|
|
|
|
|
2613
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2614
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r $fh,@_) : -r $fh; |
2615
|
|
|
|
|
|
|
} |
2616
|
|
|
|
|
|
|
elsif (-e $_) { |
2617
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2618
|
|
|
|
|
|
|
} |
2619
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2620
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2621
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-r _,@_) : -r _; |
2622
|
|
|
|
|
|
|
} |
2623
|
|
|
|
|
|
|
else { |
2624
|
|
|
|
|
|
|
|
2625
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Ehp15::*() |
2626
|
|
|
|
|
|
|
# on Windows opens the file for the path which has 5c at end. |
2627
|
|
|
|
|
|
|
# (and so on) |
2628
|
|
|
|
|
|
|
|
2629
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2630
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2631
|
0
|
|
|
|
|
0
|
my $r = -r $fh; |
2632
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2633
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($r,@_) : $r; |
2634
|
|
|
|
|
|
|
} |
2635
|
|
|
|
|
|
|
} |
2636
|
|
|
|
|
|
|
} |
2637
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2638
|
|
|
|
|
|
|
} |
2639
|
|
|
|
|
|
|
|
2640
|
|
|
|
|
|
|
# |
2641
|
|
|
|
|
|
|
# HP-15 file test -w expr |
2642
|
|
|
|
|
|
|
# |
2643
|
|
|
|
|
|
|
sub Ehp15::w(;*@) { |
2644
|
|
|
|
|
|
|
|
2645
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2646
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -w (Ehp15::w)' if @_ and not wantarray; |
2647
|
|
|
|
|
|
|
|
2648
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2649
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2650
|
|
|
|
|
|
|
} |
2651
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2652
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w $fh,@_) : -w $fh; |
2653
|
|
|
|
|
|
|
} |
2654
|
|
|
|
|
|
|
elsif (-e $_) { |
2655
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2656
|
|
|
|
|
|
|
} |
2657
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2658
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2659
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-w _,@_) : -w _; |
2660
|
|
|
|
|
|
|
} |
2661
|
|
|
|
|
|
|
else { |
2662
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2663
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
2664
|
0
|
|
|
|
|
0
|
my $w = -w $fh; |
2665
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2666
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($w,@_) : $w; |
2667
|
|
|
|
|
|
|
} |
2668
|
|
|
|
|
|
|
} |
2669
|
|
|
|
|
|
|
} |
2670
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2671
|
|
|
|
|
|
|
} |
2672
|
|
|
|
|
|
|
|
2673
|
|
|
|
|
|
|
# |
2674
|
|
|
|
|
|
|
# HP-15 file test -x expr |
2675
|
|
|
|
|
|
|
# |
2676
|
|
|
|
|
|
|
sub Ehp15::x(;*@) { |
2677
|
|
|
|
|
|
|
|
2678
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2679
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -x (Ehp15::x)' if @_ and not wantarray; |
2680
|
|
|
|
|
|
|
|
2681
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2682
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2683
|
|
|
|
|
|
|
} |
2684
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2685
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x $fh,@_) : -x $fh; |
2686
|
|
|
|
|
|
|
} |
2687
|
|
|
|
|
|
|
elsif (-e $_) { |
2688
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2689
|
|
|
|
|
|
|
} |
2690
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2691
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2692
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-x _,@_) : -x _; |
2693
|
|
|
|
|
|
|
} |
2694
|
|
|
|
|
|
|
else { |
2695
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2696
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2697
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -x $fh; |
2698
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2699
|
|
|
|
|
|
|
} |
2700
|
|
|
|
|
|
|
|
2701
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
2702
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2703
|
|
|
|
|
|
|
} |
2704
|
|
|
|
|
|
|
} |
2705
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2706
|
|
|
|
|
|
|
} |
2707
|
|
|
|
|
|
|
|
2708
|
|
|
|
|
|
|
# |
2709
|
|
|
|
|
|
|
# HP-15 file test -o expr |
2710
|
|
|
|
|
|
|
# |
2711
|
|
|
|
|
|
|
sub Ehp15::o(;*@) { |
2712
|
|
|
|
|
|
|
|
2713
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2714
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -o (Ehp15::o)' if @_ and not wantarray; |
2715
|
|
|
|
|
|
|
|
2716
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2717
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2718
|
|
|
|
|
|
|
} |
2719
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2720
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o $fh,@_) : -o $fh; |
2721
|
|
|
|
|
|
|
} |
2722
|
|
|
|
|
|
|
elsif (-e $_) { |
2723
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2724
|
|
|
|
|
|
|
} |
2725
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2726
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2727
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-o _,@_) : -o _; |
2728
|
|
|
|
|
|
|
} |
2729
|
|
|
|
|
|
|
else { |
2730
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2731
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2732
|
0
|
|
|
|
|
0
|
my $o = -o $fh; |
2733
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2734
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($o,@_) : $o; |
2735
|
|
|
|
|
|
|
} |
2736
|
|
|
|
|
|
|
} |
2737
|
|
|
|
|
|
|
} |
2738
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2739
|
|
|
|
|
|
|
} |
2740
|
|
|
|
|
|
|
|
2741
|
|
|
|
|
|
|
# |
2742
|
|
|
|
|
|
|
# HP-15 file test -R expr |
2743
|
|
|
|
|
|
|
# |
2744
|
|
|
|
|
|
|
sub Ehp15::R(;*@) { |
2745
|
|
|
|
|
|
|
|
2746
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2747
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -R (Ehp15::R)' if @_ and not wantarray; |
2748
|
|
|
|
|
|
|
|
2749
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2750
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2751
|
|
|
|
|
|
|
} |
2752
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2753
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R $fh,@_) : -R $fh; |
2754
|
|
|
|
|
|
|
} |
2755
|
|
|
|
|
|
|
elsif (-e $_) { |
2756
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2757
|
|
|
|
|
|
|
} |
2758
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2759
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2760
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-R _,@_) : -R _; |
2761
|
|
|
|
|
|
|
} |
2762
|
|
|
|
|
|
|
else { |
2763
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2764
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2765
|
0
|
|
|
|
|
0
|
my $R = -R $fh; |
2766
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2767
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($R,@_) : $R; |
2768
|
|
|
|
|
|
|
} |
2769
|
|
|
|
|
|
|
} |
2770
|
|
|
|
|
|
|
} |
2771
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2772
|
|
|
|
|
|
|
} |
2773
|
|
|
|
|
|
|
|
2774
|
|
|
|
|
|
|
# |
2775
|
|
|
|
|
|
|
# HP-15 file test -W expr |
2776
|
|
|
|
|
|
|
# |
2777
|
|
|
|
|
|
|
sub Ehp15::W(;*@) { |
2778
|
|
|
|
|
|
|
|
2779
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2780
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -W (Ehp15::W)' if @_ and not wantarray; |
2781
|
|
|
|
|
|
|
|
2782
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2783
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2784
|
|
|
|
|
|
|
} |
2785
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2786
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W $fh,@_) : -W $fh; |
2787
|
|
|
|
|
|
|
} |
2788
|
|
|
|
|
|
|
elsif (-e $_) { |
2789
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2790
|
|
|
|
|
|
|
} |
2791
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2792
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2793
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-W _,@_) : -W _; |
2794
|
|
|
|
|
|
|
} |
2795
|
|
|
|
|
|
|
else { |
2796
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2797
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
2798
|
0
|
|
|
|
|
0
|
my $W = -W $fh; |
2799
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2800
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($W,@_) : $W; |
2801
|
|
|
|
|
|
|
} |
2802
|
|
|
|
|
|
|
} |
2803
|
|
|
|
|
|
|
} |
2804
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2805
|
|
|
|
|
|
|
} |
2806
|
|
|
|
|
|
|
|
2807
|
|
|
|
|
|
|
# |
2808
|
|
|
|
|
|
|
# HP-15 file test -X expr |
2809
|
|
|
|
|
|
|
# |
2810
|
|
|
|
|
|
|
sub Ehp15::X(;*@) { |
2811
|
|
|
|
|
|
|
|
2812
|
0
|
0
|
|
0
|
1
|
0
|
local $_ = shift if @_; |
2813
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -X (Ehp15::X)' if @_ and not wantarray; |
2814
|
|
|
|
|
|
|
|
2815
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2816
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2817
|
|
|
|
|
|
|
} |
2818
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2819
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X $fh,@_) : -X $fh; |
2820
|
|
|
|
|
|
|
} |
2821
|
|
|
|
|
|
|
elsif (-e $_) { |
2822
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2823
|
|
|
|
|
|
|
} |
2824
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2825
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2826
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-X _,@_) : -X _; |
2827
|
|
|
|
|
|
|
} |
2828
|
|
|
|
|
|
|
else { |
2829
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2830
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2831
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -X $fh; |
2832
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2833
|
|
|
|
|
|
|
} |
2834
|
|
|
|
|
|
|
|
2835
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
2836
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2837
|
|
|
|
|
|
|
} |
2838
|
|
|
|
|
|
|
} |
2839
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2840
|
|
|
|
|
|
|
} |
2841
|
|
|
|
|
|
|
|
2842
|
|
|
|
|
|
|
# |
2843
|
|
|
|
|
|
|
# HP-15 file test -O expr |
2844
|
|
|
|
|
|
|
# |
2845
|
|
|
|
|
|
|
sub Ehp15::O(;*@) { |
2846
|
|
|
|
|
|
|
|
2847
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2848
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -O (Ehp15::O)' if @_ and not wantarray; |
2849
|
|
|
|
|
|
|
|
2850
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2851
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2852
|
|
|
|
|
|
|
} |
2853
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2854
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O $fh,@_) : -O $fh; |
2855
|
|
|
|
|
|
|
} |
2856
|
|
|
|
|
|
|
elsif (-e $_) { |
2857
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2858
|
|
|
|
|
|
|
} |
2859
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2860
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2861
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-O _,@_) : -O _; |
2862
|
|
|
|
|
|
|
} |
2863
|
|
|
|
|
|
|
else { |
2864
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2865
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2866
|
0
|
|
|
|
|
0
|
my $O = -O $fh; |
2867
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2868
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($O,@_) : $O; |
2869
|
|
|
|
|
|
|
} |
2870
|
|
|
|
|
|
|
} |
2871
|
|
|
|
|
|
|
} |
2872
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2873
|
|
|
|
|
|
|
} |
2874
|
|
|
|
|
|
|
|
2875
|
|
|
|
|
|
|
# |
2876
|
|
|
|
|
|
|
# HP-15 file test -e expr |
2877
|
|
|
|
|
|
|
# |
2878
|
|
|
|
|
|
|
sub Ehp15::e(;*@) { |
2879
|
|
|
|
|
|
|
|
2880
|
0
|
50
|
|
768
|
0
|
0
|
local $_ = shift if @_; |
2881
|
768
|
50
|
33
|
|
|
2954
|
croak 'Too many arguments for -e (Ehp15::e)' if @_ and not wantarray; |
2882
|
|
|
|
|
|
|
|
2883
|
768
|
|
|
|
|
3271
|
local $^W = 0; |
2884
|
|
|
|
|
|
|
|
2885
|
768
|
|
|
|
|
2487
|
my $fh = qualify_to_ref $_; |
2886
|
768
|
50
|
|
|
|
2361
|
if ($_ eq '_') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2887
|
768
|
0
|
|
|
|
3810
|
return wantarray ? (-e _,@_) : -e _; |
2888
|
|
|
|
|
|
|
} |
2889
|
|
|
|
|
|
|
|
2890
|
|
|
|
|
|
|
# return false if directory handle |
2891
|
|
|
|
|
|
|
elsif (defined Ehp15::telldir($fh)) { |
2892
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
2893
|
|
|
|
|
|
|
} |
2894
|
|
|
|
|
|
|
|
2895
|
|
|
|
|
|
|
# return true if file handle |
2896
|
|
|
|
|
|
|
elsif (defined fileno $fh) { |
2897
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2898
|
|
|
|
|
|
|
} |
2899
|
|
|
|
|
|
|
|
2900
|
|
|
|
|
|
|
elsif (-e $_) { |
2901
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2902
|
|
|
|
|
|
|
} |
2903
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2904
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2905
|
0
|
0
|
|
|
|
0
|
return wantarray ? (1,@_) : 1; |
2906
|
|
|
|
|
|
|
} |
2907
|
|
|
|
|
|
|
else { |
2908
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2909
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2910
|
0
|
|
|
|
|
0
|
my $e = -e $fh; |
2911
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2912
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($e,@_) : $e; |
2913
|
|
|
|
|
|
|
} |
2914
|
|
|
|
|
|
|
} |
2915
|
|
|
|
|
|
|
} |
2916
|
0
|
50
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2917
|
|
|
|
|
|
|
} |
2918
|
|
|
|
|
|
|
|
2919
|
|
|
|
|
|
|
# |
2920
|
|
|
|
|
|
|
# HP-15 file test -z expr |
2921
|
|
|
|
|
|
|
# |
2922
|
|
|
|
|
|
|
sub Ehp15::z(;*@) { |
2923
|
|
|
|
|
|
|
|
2924
|
768
|
0
|
|
0
|
0
|
4172
|
local $_ = shift if @_; |
2925
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -z (Ehp15::z)' if @_ and not wantarray; |
2926
|
|
|
|
|
|
|
|
2927
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2928
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2929
|
|
|
|
|
|
|
} |
2930
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2931
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z $fh,@_) : -z $fh; |
2932
|
|
|
|
|
|
|
} |
2933
|
|
|
|
|
|
|
elsif (-e $_) { |
2934
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2935
|
|
|
|
|
|
|
} |
2936
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2937
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2938
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-z _,@_) : -z _; |
2939
|
|
|
|
|
|
|
} |
2940
|
|
|
|
|
|
|
else { |
2941
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2942
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2943
|
0
|
|
|
|
|
0
|
my $z = -z $fh; |
2944
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2945
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($z,@_) : $z; |
2946
|
|
|
|
|
|
|
} |
2947
|
|
|
|
|
|
|
} |
2948
|
|
|
|
|
|
|
} |
2949
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2950
|
|
|
|
|
|
|
} |
2951
|
|
|
|
|
|
|
|
2952
|
|
|
|
|
|
|
# |
2953
|
|
|
|
|
|
|
# HP-15 file test -s expr |
2954
|
|
|
|
|
|
|
# |
2955
|
|
|
|
|
|
|
sub Ehp15::s(;*@) { |
2956
|
|
|
|
|
|
|
|
2957
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2958
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -s (Ehp15::s)' if @_ and not wantarray; |
2959
|
|
|
|
|
|
|
|
2960
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2961
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2962
|
|
|
|
|
|
|
} |
2963
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2964
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s $fh,@_) : -s $fh; |
2965
|
|
|
|
|
|
|
} |
2966
|
|
|
|
|
|
|
elsif (-e $_) { |
2967
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2968
|
|
|
|
|
|
|
} |
2969
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
2970
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
2971
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-s _,@_) : -s _; |
2972
|
|
|
|
|
|
|
} |
2973
|
|
|
|
|
|
|
else { |
2974
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
2975
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
2976
|
0
|
|
|
|
|
0
|
my $s = -s $fh; |
2977
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
2978
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($s,@_) : $s; |
2979
|
|
|
|
|
|
|
} |
2980
|
|
|
|
|
|
|
} |
2981
|
|
|
|
|
|
|
} |
2982
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
2983
|
|
|
|
|
|
|
} |
2984
|
|
|
|
|
|
|
|
2985
|
|
|
|
|
|
|
# |
2986
|
|
|
|
|
|
|
# HP-15 file test -f expr |
2987
|
|
|
|
|
|
|
# |
2988
|
|
|
|
|
|
|
sub Ehp15::f(;*@) { |
2989
|
|
|
|
|
|
|
|
2990
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
2991
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -f (Ehp15::f)' if @_ and not wantarray; |
2992
|
|
|
|
|
|
|
|
2993
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2994
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f _,@_) : -f _; |
2995
|
|
|
|
|
|
|
} |
2996
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
2997
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f $fh,@_) : -f $fh; |
2998
|
|
|
|
|
|
|
} |
2999
|
|
|
|
|
|
|
elsif (-e $_) { |
3000
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-f _,@_) : -f _; |
3001
|
|
|
|
|
|
|
} |
3002
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3003
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3004
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3005
|
|
|
|
|
|
|
} |
3006
|
|
|
|
|
|
|
else { |
3007
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3008
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3009
|
0
|
|
|
|
|
0
|
my $f = -f $fh; |
3010
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3011
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($f,@_) : $f; |
3012
|
|
|
|
|
|
|
} |
3013
|
|
|
|
|
|
|
} |
3014
|
|
|
|
|
|
|
} |
3015
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3016
|
|
|
|
|
|
|
} |
3017
|
|
|
|
|
|
|
|
3018
|
|
|
|
|
|
|
# |
3019
|
|
|
|
|
|
|
# HP-15 file test -d expr |
3020
|
|
|
|
|
|
|
# |
3021
|
|
|
|
|
|
|
sub Ehp15::d(;*@) { |
3022
|
|
|
|
|
|
|
|
3023
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3024
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -d (Ehp15::d)' if @_ and not wantarray; |
3025
|
|
|
|
|
|
|
|
3026
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3027
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d _,@_) : -d _; |
3028
|
|
|
|
|
|
|
} |
3029
|
|
|
|
|
|
|
|
3030
|
|
|
|
|
|
|
# return false if file handle or directory handle |
3031
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3032
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3033
|
|
|
|
|
|
|
} |
3034
|
|
|
|
|
|
|
elsif (-e $_) { |
3035
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d _,@_) : -d _; |
3036
|
|
|
|
|
|
|
} |
3037
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3038
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-d "$_/.",@_) : -d "$_/."; |
3039
|
|
|
|
|
|
|
} |
3040
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3041
|
|
|
|
|
|
|
} |
3042
|
|
|
|
|
|
|
|
3043
|
|
|
|
|
|
|
# |
3044
|
|
|
|
|
|
|
# HP-15 file test -l expr |
3045
|
|
|
|
|
|
|
# |
3046
|
|
|
|
|
|
|
sub Ehp15::l(;*@) { |
3047
|
|
|
|
|
|
|
|
3048
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3049
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -l (Ehp15::l)' if @_ and not wantarray; |
3050
|
|
|
|
|
|
|
|
3051
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3052
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3053
|
|
|
|
|
|
|
} |
3054
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3055
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l $fh,@_) : -l $fh; |
3056
|
|
|
|
|
|
|
} |
3057
|
|
|
|
|
|
|
elsif (-e $_) { |
3058
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3059
|
|
|
|
|
|
|
} |
3060
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3061
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3062
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-l _,@_) : -l _; |
3063
|
|
|
|
|
|
|
} |
3064
|
|
|
|
|
|
|
else { |
3065
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3066
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3067
|
0
|
|
|
|
|
0
|
my $l = -l $fh; |
3068
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3069
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($l,@_) : $l; |
3070
|
|
|
|
|
|
|
} |
3071
|
|
|
|
|
|
|
} |
3072
|
|
|
|
|
|
|
} |
3073
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3074
|
|
|
|
|
|
|
} |
3075
|
|
|
|
|
|
|
|
3076
|
|
|
|
|
|
|
# |
3077
|
|
|
|
|
|
|
# HP-15 file test -p expr |
3078
|
|
|
|
|
|
|
# |
3079
|
|
|
|
|
|
|
sub Ehp15::p(;*@) { |
3080
|
|
|
|
|
|
|
|
3081
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3082
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -p (Ehp15::p)' if @_ and not wantarray; |
3083
|
|
|
|
|
|
|
|
3084
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3085
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3086
|
|
|
|
|
|
|
} |
3087
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3088
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p $fh,@_) : -p $fh; |
3089
|
|
|
|
|
|
|
} |
3090
|
|
|
|
|
|
|
elsif (-e $_) { |
3091
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3092
|
|
|
|
|
|
|
} |
3093
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3094
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3095
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-p _,@_) : -p _; |
3096
|
|
|
|
|
|
|
} |
3097
|
|
|
|
|
|
|
else { |
3098
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3099
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3100
|
0
|
|
|
|
|
0
|
my $p = -p $fh; |
3101
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3102
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($p,@_) : $p; |
3103
|
|
|
|
|
|
|
} |
3104
|
|
|
|
|
|
|
} |
3105
|
|
|
|
|
|
|
} |
3106
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3107
|
|
|
|
|
|
|
} |
3108
|
|
|
|
|
|
|
|
3109
|
|
|
|
|
|
|
# |
3110
|
|
|
|
|
|
|
# HP-15 file test -S expr |
3111
|
|
|
|
|
|
|
# |
3112
|
|
|
|
|
|
|
sub Ehp15::S(;*@) { |
3113
|
|
|
|
|
|
|
|
3114
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3115
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -S (Ehp15::S)' if @_ and not wantarray; |
3116
|
|
|
|
|
|
|
|
3117
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3118
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3119
|
|
|
|
|
|
|
} |
3120
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3121
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S $fh,@_) : -S $fh; |
3122
|
|
|
|
|
|
|
} |
3123
|
|
|
|
|
|
|
elsif (-e $_) { |
3124
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3125
|
|
|
|
|
|
|
} |
3126
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3127
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3128
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-S _,@_) : -S _; |
3129
|
|
|
|
|
|
|
} |
3130
|
|
|
|
|
|
|
else { |
3131
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3132
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3133
|
0
|
|
|
|
|
0
|
my $S = -S $fh; |
3134
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3135
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($S,@_) : $S; |
3136
|
|
|
|
|
|
|
} |
3137
|
|
|
|
|
|
|
} |
3138
|
|
|
|
|
|
|
} |
3139
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3140
|
|
|
|
|
|
|
} |
3141
|
|
|
|
|
|
|
|
3142
|
|
|
|
|
|
|
# |
3143
|
|
|
|
|
|
|
# HP-15 file test -b expr |
3144
|
|
|
|
|
|
|
# |
3145
|
|
|
|
|
|
|
sub Ehp15::b(;*@) { |
3146
|
|
|
|
|
|
|
|
3147
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3148
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -b (Ehp15::b)' if @_ and not wantarray; |
3149
|
|
|
|
|
|
|
|
3150
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3151
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3152
|
|
|
|
|
|
|
} |
3153
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3154
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b $fh,@_) : -b $fh; |
3155
|
|
|
|
|
|
|
} |
3156
|
|
|
|
|
|
|
elsif (-e $_) { |
3157
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3158
|
|
|
|
|
|
|
} |
3159
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3160
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3161
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-b _,@_) : -b _; |
3162
|
|
|
|
|
|
|
} |
3163
|
|
|
|
|
|
|
else { |
3164
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3165
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3166
|
0
|
|
|
|
|
0
|
my $b = -b $fh; |
3167
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3168
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($b,@_) : $b; |
3169
|
|
|
|
|
|
|
} |
3170
|
|
|
|
|
|
|
} |
3171
|
|
|
|
|
|
|
} |
3172
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3173
|
|
|
|
|
|
|
} |
3174
|
|
|
|
|
|
|
|
3175
|
|
|
|
|
|
|
# |
3176
|
|
|
|
|
|
|
# HP-15 file test -c expr |
3177
|
|
|
|
|
|
|
# |
3178
|
|
|
|
|
|
|
sub Ehp15::c(;*@) { |
3179
|
|
|
|
|
|
|
|
3180
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3181
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -c (Ehp15::c)' if @_ and not wantarray; |
3182
|
|
|
|
|
|
|
|
3183
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3184
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3185
|
|
|
|
|
|
|
} |
3186
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3187
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c $fh,@_) : -c $fh; |
3188
|
|
|
|
|
|
|
} |
3189
|
|
|
|
|
|
|
elsif (-e $_) { |
3190
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3191
|
|
|
|
|
|
|
} |
3192
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3193
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3194
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-c _,@_) : -c _; |
3195
|
|
|
|
|
|
|
} |
3196
|
|
|
|
|
|
|
else { |
3197
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3198
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3199
|
0
|
|
|
|
|
0
|
my $c = -c $fh; |
3200
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3201
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($c,@_) : $c; |
3202
|
|
|
|
|
|
|
} |
3203
|
|
|
|
|
|
|
} |
3204
|
|
|
|
|
|
|
} |
3205
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3206
|
|
|
|
|
|
|
} |
3207
|
|
|
|
|
|
|
|
3208
|
|
|
|
|
|
|
# |
3209
|
|
|
|
|
|
|
# HP-15 file test -u expr |
3210
|
|
|
|
|
|
|
# |
3211
|
|
|
|
|
|
|
sub Ehp15::u(;*@) { |
3212
|
|
|
|
|
|
|
|
3213
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3214
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -u (Ehp15::u)' if @_ and not wantarray; |
3215
|
|
|
|
|
|
|
|
3216
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3217
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3218
|
|
|
|
|
|
|
} |
3219
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3220
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u $fh,@_) : -u $fh; |
3221
|
|
|
|
|
|
|
} |
3222
|
|
|
|
|
|
|
elsif (-e $_) { |
3223
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3224
|
|
|
|
|
|
|
} |
3225
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3226
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3227
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-u _,@_) : -u _; |
3228
|
|
|
|
|
|
|
} |
3229
|
|
|
|
|
|
|
else { |
3230
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3231
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3232
|
0
|
|
|
|
|
0
|
my $u = -u $fh; |
3233
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3234
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($u,@_) : $u; |
3235
|
|
|
|
|
|
|
} |
3236
|
|
|
|
|
|
|
} |
3237
|
|
|
|
|
|
|
} |
3238
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3239
|
|
|
|
|
|
|
} |
3240
|
|
|
|
|
|
|
|
3241
|
|
|
|
|
|
|
# |
3242
|
|
|
|
|
|
|
# HP-15 file test -g expr |
3243
|
|
|
|
|
|
|
# |
3244
|
|
|
|
|
|
|
sub Ehp15::g(;*@) { |
3245
|
|
|
|
|
|
|
|
3246
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3247
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -g (Ehp15::g)' if @_ and not wantarray; |
3248
|
|
|
|
|
|
|
|
3249
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3250
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3251
|
|
|
|
|
|
|
} |
3252
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3253
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g $fh,@_) : -g $fh; |
3254
|
|
|
|
|
|
|
} |
3255
|
|
|
|
|
|
|
elsif (-e $_) { |
3256
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3257
|
|
|
|
|
|
|
} |
3258
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3259
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3260
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-g _,@_) : -g _; |
3261
|
|
|
|
|
|
|
} |
3262
|
|
|
|
|
|
|
else { |
3263
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3264
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3265
|
0
|
|
|
|
|
0
|
my $g = -g $fh; |
3266
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3267
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($g,@_) : $g; |
3268
|
|
|
|
|
|
|
} |
3269
|
|
|
|
|
|
|
} |
3270
|
|
|
|
|
|
|
} |
3271
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3272
|
|
|
|
|
|
|
} |
3273
|
|
|
|
|
|
|
|
3274
|
|
|
|
|
|
|
# |
3275
|
|
|
|
|
|
|
# HP-15 file test -k expr |
3276
|
|
|
|
|
|
|
# |
3277
|
|
|
|
|
|
|
sub Ehp15::k(;*@) { |
3278
|
|
|
|
|
|
|
|
3279
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3280
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -k (Ehp15::k)' if @_ and not wantarray; |
3281
|
|
|
|
|
|
|
|
3282
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3283
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3284
|
|
|
|
|
|
|
} |
3285
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3286
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3287
|
|
|
|
|
|
|
} |
3288
|
|
|
|
|
|
|
elsif ($] =~ /^5\.008/oxms) { |
3289
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
3290
|
|
|
|
|
|
|
} |
3291
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($_,@_) : $_; |
3292
|
|
|
|
|
|
|
} |
3293
|
|
|
|
|
|
|
|
3294
|
|
|
|
|
|
|
# |
3295
|
|
|
|
|
|
|
# HP-15 file test -T expr |
3296
|
|
|
|
|
|
|
# |
3297
|
|
|
|
|
|
|
sub Ehp15::T(;*@) { |
3298
|
|
|
|
|
|
|
|
3299
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3300
|
|
|
|
|
|
|
|
3301
|
|
|
|
|
|
|
# Use of croak without parentheses makes die on Strawberry Perl 5.008 and 5.010, like: |
3302
|
|
|
|
|
|
|
# croak 'Too many arguments for -T (Ehp15::T)'; |
3303
|
|
|
|
|
|
|
# Must be used by parentheses like: |
3304
|
|
|
|
|
|
|
# croak('Too many arguments for -T (Ehp15::T)'); |
3305
|
|
|
|
|
|
|
|
3306
|
0
|
0
|
0
|
|
|
0
|
if (@_ and not wantarray) { |
3307
|
0
|
|
|
|
|
0
|
croak('Too many arguments for -T (Ehp15::T)'); |
3308
|
|
|
|
|
|
|
} |
3309
|
|
|
|
|
|
|
|
3310
|
0
|
|
|
|
|
0
|
my $T = 1; |
3311
|
|
|
|
|
|
|
|
3312
|
0
|
|
|
|
|
0
|
my $fh = qualify_to_ref $_; |
3313
|
0
|
0
|
|
|
|
0
|
if (defined fileno $fh) { |
3314
|
|
|
|
|
|
|
|
3315
|
0
|
0
|
|
|
|
0
|
if (defined Ehp15::telldir($fh)) { |
3316
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3317
|
|
|
|
|
|
|
} |
3318
|
|
|
|
|
|
|
|
3319
|
|
|
|
|
|
|
# P.813 29.2.176. tell |
3320
|
|
|
|
|
|
|
# in Chapter 29: Functions |
3321
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
3322
|
|
|
|
|
|
|
|
3323
|
|
|
|
|
|
|
# P.970 tell |
3324
|
|
|
|
|
|
|
# in Chapter 27: Functions |
3325
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
3326
|
|
|
|
|
|
|
|
3327
|
|
|
|
|
|
|
# (and so on) |
3328
|
|
|
|
|
|
|
|
3329
|
0
|
|
|
|
|
0
|
my $systell = sysseek $fh, 0, 1; |
3330
|
|
|
|
|
|
|
|
3331
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3332
|
|
|
|
|
|
|
|
3333
|
|
|
|
|
|
|
# P.163 Binary file check in Little Perl Parlor 16 |
3334
|
|
|
|
|
|
|
# of Book No. T1008901080816 ZASSHI 08901-8 UNIX MAGAZINE 1993 Aug VOL8#8 |
3335
|
|
|
|
|
|
|
# (and so on) |
3336
|
|
|
|
|
|
|
|
3337
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3338
|
0
|
|
|
|
|
0
|
$T = ''; |
3339
|
|
|
|
|
|
|
} |
3340
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3341
|
0
|
|
|
|
|
0
|
$T = ''; |
3342
|
|
|
|
|
|
|
} |
3343
|
|
|
|
|
|
|
} |
3344
|
|
|
|
|
|
|
|
3345
|
|
|
|
|
|
|
# 0 byte or eof |
3346
|
|
|
|
|
|
|
else { |
3347
|
0
|
|
|
|
|
0
|
$T = 1; |
3348
|
|
|
|
|
|
|
} |
3349
|
|
|
|
|
|
|
|
3350
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
3351
|
0
|
|
|
|
|
0
|
sysseek $fh, $systell, 0; |
3352
|
|
|
|
|
|
|
} |
3353
|
|
|
|
|
|
|
else { |
3354
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
3355
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3356
|
|
|
|
|
|
|
} |
3357
|
|
|
|
|
|
|
|
3358
|
0
|
|
|
|
|
0
|
$fh = gensym(); |
3359
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3360
|
|
|
|
|
|
|
} |
3361
|
|
|
|
|
|
|
else { |
3362
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3363
|
|
|
|
|
|
|
} |
3364
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3365
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3366
|
0
|
|
|
|
|
0
|
$T = ''; |
3367
|
|
|
|
|
|
|
} |
3368
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3369
|
0
|
|
|
|
|
0
|
$T = ''; |
3370
|
|
|
|
|
|
|
} |
3371
|
|
|
|
|
|
|
} |
3372
|
|
|
|
|
|
|
|
3373
|
|
|
|
|
|
|
# 0 byte or eof |
3374
|
|
|
|
|
|
|
else { |
3375
|
0
|
|
|
|
|
0
|
$T = 1; |
3376
|
|
|
|
|
|
|
} |
3377
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
3378
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3379
|
|
|
|
|
|
|
} |
3380
|
|
|
|
|
|
|
|
3381
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($T,@_) : $T; |
3382
|
|
|
|
|
|
|
} |
3383
|
|
|
|
|
|
|
|
3384
|
|
|
|
|
|
|
# |
3385
|
|
|
|
|
|
|
# HP-15 file test -B expr |
3386
|
|
|
|
|
|
|
# |
3387
|
|
|
|
|
|
|
sub Ehp15::B(;*@) { |
3388
|
|
|
|
|
|
|
|
3389
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3390
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -B (Ehp15::B)' if @_ and not wantarray; |
3391
|
0
|
|
|
|
|
0
|
my $B = ''; |
3392
|
|
|
|
|
|
|
|
3393
|
0
|
|
|
|
|
0
|
my $fh = qualify_to_ref $_; |
3394
|
0
|
0
|
|
|
|
0
|
if (defined fileno $fh) { |
3395
|
|
|
|
|
|
|
|
3396
|
0
|
0
|
|
|
|
0
|
if (defined Ehp15::telldir($fh)) { |
3397
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3398
|
|
|
|
|
|
|
} |
3399
|
|
|
|
|
|
|
|
3400
|
0
|
|
|
|
|
0
|
my $systell = sysseek $fh, 0, 1; |
3401
|
|
|
|
|
|
|
|
3402
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3403
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3404
|
0
|
|
|
|
|
0
|
$B = 1; |
3405
|
|
|
|
|
|
|
} |
3406
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3407
|
0
|
|
|
|
|
0
|
$B = 1; |
3408
|
|
|
|
|
|
|
} |
3409
|
|
|
|
|
|
|
} |
3410
|
|
|
|
|
|
|
|
3411
|
|
|
|
|
|
|
# 0 byte or eof |
3412
|
|
|
|
|
|
|
else { |
3413
|
0
|
|
|
|
|
0
|
$B = 1; |
3414
|
|
|
|
|
|
|
} |
3415
|
|
|
|
|
|
|
|
3416
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
3417
|
0
|
|
|
|
|
0
|
sysseek $fh, $systell, 0; |
3418
|
|
|
|
|
|
|
} |
3419
|
|
|
|
|
|
|
else { |
3420
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
3421
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3422
|
|
|
|
|
|
|
} |
3423
|
|
|
|
|
|
|
|
3424
|
0
|
|
|
|
|
0
|
$fh = gensym(); |
3425
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3426
|
|
|
|
|
|
|
} |
3427
|
|
|
|
|
|
|
else { |
3428
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3429
|
|
|
|
|
|
|
} |
3430
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
3431
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
3432
|
0
|
|
|
|
|
0
|
$B = 1; |
3433
|
|
|
|
|
|
|
} |
3434
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
3435
|
0
|
|
|
|
|
0
|
$B = 1; |
3436
|
|
|
|
|
|
|
} |
3437
|
|
|
|
|
|
|
} |
3438
|
|
|
|
|
|
|
|
3439
|
|
|
|
|
|
|
# 0 byte or eof |
3440
|
|
|
|
|
|
|
else { |
3441
|
0
|
|
|
|
|
0
|
$B = 1; |
3442
|
|
|
|
|
|
|
} |
3443
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
3444
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3445
|
|
|
|
|
|
|
} |
3446
|
|
|
|
|
|
|
|
3447
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($B,@_) : $B; |
3448
|
|
|
|
|
|
|
} |
3449
|
|
|
|
|
|
|
|
3450
|
|
|
|
|
|
|
# |
3451
|
|
|
|
|
|
|
# HP-15 file test -M expr |
3452
|
|
|
|
|
|
|
# |
3453
|
|
|
|
|
|
|
sub Ehp15::M(;*@) { |
3454
|
|
|
|
|
|
|
|
3455
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3456
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -M (Ehp15::M)' if @_ and not wantarray; |
3457
|
|
|
|
|
|
|
|
3458
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3459
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3460
|
|
|
|
|
|
|
} |
3461
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3462
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M $fh,@_) : -M $fh; |
3463
|
|
|
|
|
|
|
} |
3464
|
|
|
|
|
|
|
elsif (-e $_) { |
3465
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3466
|
|
|
|
|
|
|
} |
3467
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3468
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3469
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-M _,@_) : -M _; |
3470
|
|
|
|
|
|
|
} |
3471
|
|
|
|
|
|
|
else { |
3472
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3473
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3474
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3475
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3476
|
0
|
|
|
|
|
0
|
my $M = ($^T - $mtime) / (24*60*60); |
3477
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($M,@_) : $M; |
3478
|
|
|
|
|
|
|
} |
3479
|
|
|
|
|
|
|
} |
3480
|
|
|
|
|
|
|
} |
3481
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3482
|
|
|
|
|
|
|
} |
3483
|
|
|
|
|
|
|
|
3484
|
|
|
|
|
|
|
# |
3485
|
|
|
|
|
|
|
# HP-15 file test -A expr |
3486
|
|
|
|
|
|
|
# |
3487
|
|
|
|
|
|
|
sub Ehp15::A(;*@) { |
3488
|
|
|
|
|
|
|
|
3489
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3490
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -A (Ehp15::A)' if @_ and not wantarray; |
3491
|
|
|
|
|
|
|
|
3492
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3493
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3494
|
|
|
|
|
|
|
} |
3495
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3496
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A $fh,@_) : -A $fh; |
3497
|
|
|
|
|
|
|
} |
3498
|
|
|
|
|
|
|
elsif (-e $_) { |
3499
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3500
|
|
|
|
|
|
|
} |
3501
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3502
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3503
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-A _,@_) : -A _; |
3504
|
|
|
|
|
|
|
} |
3505
|
|
|
|
|
|
|
else { |
3506
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3507
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3508
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3509
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3510
|
0
|
|
|
|
|
0
|
my $A = ($^T - $atime) / (24*60*60); |
3511
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($A,@_) : $A; |
3512
|
|
|
|
|
|
|
} |
3513
|
|
|
|
|
|
|
} |
3514
|
|
|
|
|
|
|
} |
3515
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3516
|
|
|
|
|
|
|
} |
3517
|
|
|
|
|
|
|
|
3518
|
|
|
|
|
|
|
# |
3519
|
|
|
|
|
|
|
# HP-15 file test -C expr |
3520
|
|
|
|
|
|
|
# |
3521
|
|
|
|
|
|
|
sub Ehp15::C(;*@) { |
3522
|
|
|
|
|
|
|
|
3523
|
0
|
0
|
|
0
|
0
|
0
|
local $_ = shift if @_; |
3524
|
0
|
0
|
0
|
|
|
0
|
croak 'Too many arguments for -C (Ehp15::C)' if @_ and not wantarray; |
3525
|
|
|
|
|
|
|
|
3526
|
0
|
0
|
|
|
|
0
|
if ($_ eq '_') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
3527
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3528
|
|
|
|
|
|
|
} |
3529
|
|
|
|
|
|
|
elsif (defined fileno(my $fh = qualify_to_ref $_)) { |
3530
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C $fh,@_) : -C $fh; |
3531
|
|
|
|
|
|
|
} |
3532
|
|
|
|
|
|
|
elsif (-e $_) { |
3533
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3534
|
|
|
|
|
|
|
} |
3535
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3536
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3537
|
0
|
0
|
|
|
|
0
|
return wantarray ? (-C _,@_) : -C _; |
3538
|
|
|
|
|
|
|
} |
3539
|
|
|
|
|
|
|
else { |
3540
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3541
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3542
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
3543
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3544
|
0
|
|
|
|
|
0
|
my $C = ($^T - $ctime) / (24*60*60); |
3545
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($C,@_) : $C; |
3546
|
|
|
|
|
|
|
} |
3547
|
|
|
|
|
|
|
} |
3548
|
|
|
|
|
|
|
} |
3549
|
0
|
0
|
|
|
|
0
|
return wantarray ? (undef,@_) : undef; |
3550
|
|
|
|
|
|
|
} |
3551
|
|
|
|
|
|
|
|
3552
|
|
|
|
|
|
|
# |
3553
|
|
|
|
|
|
|
# HP-15 stacked file test $_ |
3554
|
|
|
|
|
|
|
# |
3555
|
|
|
|
|
|
|
sub Ehp15::filetest_ { |
3556
|
|
|
|
|
|
|
|
3557
|
0
|
|
|
0
|
0
|
0
|
my $filetest = substr(pop @_, 1); |
3558
|
|
|
|
|
|
|
|
3559
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{Ehp15::${filetest}_}) { |
3560
|
0
|
|
|
|
|
0
|
return ''; |
3561
|
|
|
|
|
|
|
} |
3562
|
0
|
|
|
|
|
0
|
for my $filetest (CORE::reverse @_) { |
3563
|
0
|
0
|
|
|
|
0
|
unless (CORE::eval qq{ $filetest _ }) { |
3564
|
0
|
|
|
|
|
0
|
return ''; |
3565
|
|
|
|
|
|
|
} |
3566
|
|
|
|
|
|
|
} |
3567
|
0
|
|
|
|
|
0
|
return 1; |
3568
|
|
|
|
|
|
|
} |
3569
|
|
|
|
|
|
|
|
3570
|
|
|
|
|
|
|
# |
3571
|
|
|
|
|
|
|
# HP-15 file test -r $_ |
3572
|
|
|
|
|
|
|
# |
3573
|
|
|
|
|
|
|
sub Ehp15::r_() { |
3574
|
|
|
|
|
|
|
|
3575
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3576
|
0
|
0
|
|
|
|
0
|
return -r _ ? 1 : ''; |
3577
|
|
|
|
|
|
|
} |
3578
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3579
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3580
|
0
|
0
|
|
|
|
0
|
return -r _ ? 1 : ''; |
3581
|
|
|
|
|
|
|
} |
3582
|
|
|
|
|
|
|
else { |
3583
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3584
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3585
|
0
|
|
|
|
|
0
|
my $r = -r $fh; |
3586
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3587
|
0
|
0
|
|
|
|
0
|
return $r ? 1 : ''; |
3588
|
|
|
|
|
|
|
} |
3589
|
|
|
|
|
|
|
} |
3590
|
|
|
|
|
|
|
} |
3591
|
|
|
|
|
|
|
|
3592
|
|
|
|
|
|
|
# 10.10. Returning Failure |
3593
|
|
|
|
|
|
|
# in Chapter 10. Subroutines |
3594
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
3595
|
|
|
|
|
|
|
# (and so on) |
3596
|
|
|
|
|
|
|
|
3597
|
|
|
|
|
|
|
# 2010-01-26 The difference of "return;" and "return undef;" |
3598
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/gfx/20100126/1264474754 |
3599
|
|
|
|
|
|
|
# |
3600
|
|
|
|
|
|
|
# "Perl Best Practices" recommends to use "return;"*1 to return nothing, but |
3601
|
|
|
|
|
|
|
# it might be wrong in some cases. If you use this idiom for those functions |
3602
|
|
|
|
|
|
|
# which are expected to return a scalar value, e.g. searching functions, the |
3603
|
|
|
|
|
|
|
# user of those functions will be surprised at what they return in list |
3604
|
|
|
|
|
|
|
# context, an empty list - note that many functions and all the methods |
3605
|
|
|
|
|
|
|
# evaluate their arguments in list context. You'd better to use "return undef;" |
3606
|
|
|
|
|
|
|
# for such scalar functions. |
3607
|
|
|
|
|
|
|
# |
3608
|
|
|
|
|
|
|
# sub search_something { |
3609
|
|
|
|
|
|
|
# my($arg) = @_; |
3610
|
|
|
|
|
|
|
# # search_something... |
3611
|
|
|
|
|
|
|
# if(defined $found){ |
3612
|
|
|
|
|
|
|
# return $found; |
3613
|
|
|
|
|
|
|
# } |
3614
|
|
|
|
|
|
|
# return; # XXX: you'd better to "return undef;" |
3615
|
|
|
|
|
|
|
# } |
3616
|
|
|
|
|
|
|
# |
3617
|
|
|
|
|
|
|
# # ... |
3618
|
|
|
|
|
|
|
# |
3619
|
|
|
|
|
|
|
# # you'll get what you want, but ... |
3620
|
|
|
|
|
|
|
# my $something = search_something($source); |
3621
|
|
|
|
|
|
|
# |
3622
|
|
|
|
|
|
|
# # you won't get what you want here. |
3623
|
|
|
|
|
|
|
# # @_ for doit() is (-foo => $opt), not (undef, -foo => $opt). |
3624
|
|
|
|
|
|
|
# $obj->doit(search_something($source), -option=> $optval); |
3625
|
|
|
|
|
|
|
# |
3626
|
|
|
|
|
|
|
# # you have to use the "scalar" operator in such a case. |
3627
|
|
|
|
|
|
|
# $obj->doit(scalar search_something($source), ...); |
3628
|
|
|
|
|
|
|
# |
3629
|
|
|
|
|
|
|
# *1: it returns an empty list in list context, or returns undef in scalar |
3630
|
|
|
|
|
|
|
# context |
3631
|
|
|
|
|
|
|
# |
3632
|
|
|
|
|
|
|
# (and so on) |
3633
|
|
|
|
|
|
|
|
3634
|
0
|
|
|
|
|
0
|
return undef; |
3635
|
|
|
|
|
|
|
} |
3636
|
|
|
|
|
|
|
|
3637
|
|
|
|
|
|
|
# |
3638
|
|
|
|
|
|
|
# HP-15 file test -w $_ |
3639
|
|
|
|
|
|
|
# |
3640
|
|
|
|
|
|
|
sub Ehp15::w_() { |
3641
|
|
|
|
|
|
|
|
3642
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3643
|
0
|
0
|
|
|
|
0
|
return -w _ ? 1 : ''; |
3644
|
|
|
|
|
|
|
} |
3645
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3646
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3647
|
0
|
0
|
|
|
|
0
|
return -w _ ? 1 : ''; |
3648
|
|
|
|
|
|
|
} |
3649
|
|
|
|
|
|
|
else { |
3650
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3651
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
3652
|
0
|
|
|
|
|
0
|
my $w = -w $fh; |
3653
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3654
|
0
|
0
|
|
|
|
0
|
return $w ? 1 : ''; |
3655
|
|
|
|
|
|
|
} |
3656
|
|
|
|
|
|
|
} |
3657
|
|
|
|
|
|
|
} |
3658
|
0
|
|
|
|
|
0
|
return undef; |
3659
|
|
|
|
|
|
|
} |
3660
|
|
|
|
|
|
|
|
3661
|
|
|
|
|
|
|
# |
3662
|
|
|
|
|
|
|
# HP-15 file test -x $_ |
3663
|
|
|
|
|
|
|
# |
3664
|
|
|
|
|
|
|
sub Ehp15::x_() { |
3665
|
|
|
|
|
|
|
|
3666
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3667
|
0
|
0
|
|
|
|
0
|
return -x _ ? 1 : ''; |
3668
|
|
|
|
|
|
|
} |
3669
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3670
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3671
|
0
|
0
|
|
|
|
0
|
return -x _ ? 1 : ''; |
3672
|
|
|
|
|
|
|
} |
3673
|
|
|
|
|
|
|
else { |
3674
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3675
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3676
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -x $fh; |
3677
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3678
|
|
|
|
|
|
|
} |
3679
|
|
|
|
|
|
|
|
3680
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
3681
|
0
|
|
|
|
|
0
|
return ''; |
3682
|
|
|
|
|
|
|
} |
3683
|
|
|
|
|
|
|
} |
3684
|
0
|
|
|
|
|
0
|
return undef; |
3685
|
|
|
|
|
|
|
} |
3686
|
|
|
|
|
|
|
|
3687
|
|
|
|
|
|
|
# |
3688
|
|
|
|
|
|
|
# HP-15 file test -o $_ |
3689
|
|
|
|
|
|
|
# |
3690
|
|
|
|
|
|
|
sub Ehp15::o_() { |
3691
|
|
|
|
|
|
|
|
3692
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3693
|
0
|
0
|
|
|
|
0
|
return -o _ ? 1 : ''; |
3694
|
|
|
|
|
|
|
} |
3695
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3696
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3697
|
0
|
0
|
|
|
|
0
|
return -o _ ? 1 : ''; |
3698
|
|
|
|
|
|
|
} |
3699
|
|
|
|
|
|
|
else { |
3700
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3701
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3702
|
0
|
|
|
|
|
0
|
my $o = -o $fh; |
3703
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3704
|
0
|
0
|
|
|
|
0
|
return $o ? 1 : ''; |
3705
|
|
|
|
|
|
|
} |
3706
|
|
|
|
|
|
|
} |
3707
|
|
|
|
|
|
|
} |
3708
|
0
|
|
|
|
|
0
|
return undef; |
3709
|
|
|
|
|
|
|
} |
3710
|
|
|
|
|
|
|
|
3711
|
|
|
|
|
|
|
# |
3712
|
|
|
|
|
|
|
# HP-15 file test -R $_ |
3713
|
|
|
|
|
|
|
# |
3714
|
|
|
|
|
|
|
sub Ehp15::R_() { |
3715
|
|
|
|
|
|
|
|
3716
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3717
|
0
|
0
|
|
|
|
0
|
return -R _ ? 1 : ''; |
3718
|
|
|
|
|
|
|
} |
3719
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3720
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3721
|
0
|
0
|
|
|
|
0
|
return -R _ ? 1 : ''; |
3722
|
|
|
|
|
|
|
} |
3723
|
|
|
|
|
|
|
else { |
3724
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3725
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3726
|
0
|
|
|
|
|
0
|
my $R = -R $fh; |
3727
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3728
|
0
|
0
|
|
|
|
0
|
return $R ? 1 : ''; |
3729
|
|
|
|
|
|
|
} |
3730
|
|
|
|
|
|
|
} |
3731
|
|
|
|
|
|
|
} |
3732
|
0
|
|
|
|
|
0
|
return undef; |
3733
|
|
|
|
|
|
|
} |
3734
|
|
|
|
|
|
|
|
3735
|
|
|
|
|
|
|
# |
3736
|
|
|
|
|
|
|
# HP-15 file test -W $_ |
3737
|
|
|
|
|
|
|
# |
3738
|
|
|
|
|
|
|
sub Ehp15::W_() { |
3739
|
|
|
|
|
|
|
|
3740
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3741
|
0
|
0
|
|
|
|
0
|
return -W _ ? 1 : ''; |
3742
|
|
|
|
|
|
|
} |
3743
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3744
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3745
|
0
|
0
|
|
|
|
0
|
return -W _ ? 1 : ''; |
3746
|
|
|
|
|
|
|
} |
3747
|
|
|
|
|
|
|
else { |
3748
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3749
|
0
|
0
|
|
|
|
0
|
if (_open_a($fh, $_)) { |
3750
|
0
|
|
|
|
|
0
|
my $W = -W $fh; |
3751
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3752
|
0
|
0
|
|
|
|
0
|
return $W ? 1 : ''; |
3753
|
|
|
|
|
|
|
} |
3754
|
|
|
|
|
|
|
} |
3755
|
|
|
|
|
|
|
} |
3756
|
0
|
|
|
|
|
0
|
return undef; |
3757
|
|
|
|
|
|
|
} |
3758
|
|
|
|
|
|
|
|
3759
|
|
|
|
|
|
|
# |
3760
|
|
|
|
|
|
|
# HP-15 file test -X $_ |
3761
|
|
|
|
|
|
|
# |
3762
|
|
|
|
|
|
|
sub Ehp15::X_() { |
3763
|
|
|
|
|
|
|
|
3764
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3765
|
0
|
0
|
|
|
|
0
|
return -X _ ? 1 : ''; |
3766
|
|
|
|
|
|
|
} |
3767
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3768
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3769
|
0
|
0
|
|
|
|
0
|
return -X _ ? 1 : ''; |
3770
|
|
|
|
|
|
|
} |
3771
|
|
|
|
|
|
|
else { |
3772
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3773
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3774
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -X $fh; |
3775
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3776
|
|
|
|
|
|
|
} |
3777
|
|
|
|
|
|
|
|
3778
|
|
|
|
|
|
|
# filename is not .COM .EXE .BAT .CMD |
3779
|
0
|
|
|
|
|
0
|
return ''; |
3780
|
|
|
|
|
|
|
} |
3781
|
|
|
|
|
|
|
} |
3782
|
0
|
|
|
|
|
0
|
return undef; |
3783
|
|
|
|
|
|
|
} |
3784
|
|
|
|
|
|
|
|
3785
|
|
|
|
|
|
|
# |
3786
|
|
|
|
|
|
|
# HP-15 file test -O $_ |
3787
|
|
|
|
|
|
|
# |
3788
|
|
|
|
|
|
|
sub Ehp15::O_() { |
3789
|
|
|
|
|
|
|
|
3790
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3791
|
0
|
0
|
|
|
|
0
|
return -O _ ? 1 : ''; |
3792
|
|
|
|
|
|
|
} |
3793
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3794
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3795
|
0
|
0
|
|
|
|
0
|
return -O _ ? 1 : ''; |
3796
|
|
|
|
|
|
|
} |
3797
|
|
|
|
|
|
|
else { |
3798
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3799
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3800
|
0
|
|
|
|
|
0
|
my $O = -O $fh; |
3801
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3802
|
0
|
0
|
|
|
|
0
|
return $O ? 1 : ''; |
3803
|
|
|
|
|
|
|
} |
3804
|
|
|
|
|
|
|
} |
3805
|
|
|
|
|
|
|
} |
3806
|
0
|
|
|
|
|
0
|
return undef; |
3807
|
|
|
|
|
|
|
} |
3808
|
|
|
|
|
|
|
|
3809
|
|
|
|
|
|
|
# |
3810
|
|
|
|
|
|
|
# HP-15 file test -e $_ |
3811
|
|
|
|
|
|
|
# |
3812
|
|
|
|
|
|
|
sub Ehp15::e_() { |
3813
|
|
|
|
|
|
|
|
3814
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3815
|
0
|
|
|
|
|
0
|
return 1; |
3816
|
|
|
|
|
|
|
} |
3817
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3818
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3819
|
0
|
|
|
|
|
0
|
return 1; |
3820
|
|
|
|
|
|
|
} |
3821
|
|
|
|
|
|
|
else { |
3822
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3823
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3824
|
0
|
|
|
|
|
0
|
my $e = -e $fh; |
3825
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3826
|
0
|
0
|
|
|
|
0
|
return $e ? 1 : ''; |
3827
|
|
|
|
|
|
|
} |
3828
|
|
|
|
|
|
|
} |
3829
|
|
|
|
|
|
|
} |
3830
|
0
|
|
|
|
|
0
|
return undef; |
3831
|
|
|
|
|
|
|
} |
3832
|
|
|
|
|
|
|
|
3833
|
|
|
|
|
|
|
# |
3834
|
|
|
|
|
|
|
# HP-15 file test -z $_ |
3835
|
|
|
|
|
|
|
# |
3836
|
|
|
|
|
|
|
sub Ehp15::z_() { |
3837
|
|
|
|
|
|
|
|
3838
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3839
|
0
|
0
|
|
|
|
0
|
return -z _ ? 1 : ''; |
3840
|
|
|
|
|
|
|
} |
3841
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3842
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3843
|
0
|
0
|
|
|
|
0
|
return -z _ ? 1 : ''; |
3844
|
|
|
|
|
|
|
} |
3845
|
|
|
|
|
|
|
else { |
3846
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3847
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3848
|
0
|
|
|
|
|
0
|
my $z = -z $fh; |
3849
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3850
|
0
|
0
|
|
|
|
0
|
return $z ? 1 : ''; |
3851
|
|
|
|
|
|
|
} |
3852
|
|
|
|
|
|
|
} |
3853
|
|
|
|
|
|
|
} |
3854
|
0
|
|
|
|
|
0
|
return undef; |
3855
|
|
|
|
|
|
|
} |
3856
|
|
|
|
|
|
|
|
3857
|
|
|
|
|
|
|
# |
3858
|
|
|
|
|
|
|
# HP-15 file test -s $_ |
3859
|
|
|
|
|
|
|
# |
3860
|
|
|
|
|
|
|
sub Ehp15::s_() { |
3861
|
|
|
|
|
|
|
|
3862
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3863
|
0
|
|
|
|
|
0
|
return -s _; |
3864
|
|
|
|
|
|
|
} |
3865
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3866
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3867
|
0
|
|
|
|
|
0
|
return -s _; |
3868
|
|
|
|
|
|
|
} |
3869
|
|
|
|
|
|
|
else { |
3870
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3871
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3872
|
0
|
|
|
|
|
0
|
my $s = -s $fh; |
3873
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3874
|
0
|
|
|
|
|
0
|
return $s; |
3875
|
|
|
|
|
|
|
} |
3876
|
|
|
|
|
|
|
} |
3877
|
|
|
|
|
|
|
} |
3878
|
0
|
|
|
|
|
0
|
return undef; |
3879
|
|
|
|
|
|
|
} |
3880
|
|
|
|
|
|
|
|
3881
|
|
|
|
|
|
|
# |
3882
|
|
|
|
|
|
|
# HP-15 file test -f $_ |
3883
|
|
|
|
|
|
|
# |
3884
|
|
|
|
|
|
|
sub Ehp15::f_() { |
3885
|
|
|
|
|
|
|
|
3886
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3887
|
0
|
0
|
|
|
|
0
|
return -f _ ? 1 : ''; |
3888
|
|
|
|
|
|
|
} |
3889
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3890
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3891
|
0
|
|
|
|
|
0
|
return ''; |
3892
|
|
|
|
|
|
|
} |
3893
|
|
|
|
|
|
|
else { |
3894
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3895
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3896
|
0
|
|
|
|
|
0
|
my $f = -f $fh; |
3897
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3898
|
0
|
0
|
|
|
|
0
|
return $f ? 1 : ''; |
3899
|
|
|
|
|
|
|
} |
3900
|
|
|
|
|
|
|
} |
3901
|
|
|
|
|
|
|
} |
3902
|
0
|
|
|
|
|
0
|
return undef; |
3903
|
|
|
|
|
|
|
} |
3904
|
|
|
|
|
|
|
|
3905
|
|
|
|
|
|
|
# |
3906
|
|
|
|
|
|
|
# HP-15 file test -d $_ |
3907
|
|
|
|
|
|
|
# |
3908
|
|
|
|
|
|
|
sub Ehp15::d_() { |
3909
|
|
|
|
|
|
|
|
3910
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3911
|
0
|
0
|
|
|
|
0
|
return -d _ ? 1 : ''; |
3912
|
|
|
|
|
|
|
} |
3913
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3914
|
0
|
0
|
|
|
|
0
|
return -d "$_/." ? 1 : ''; |
3915
|
|
|
|
|
|
|
} |
3916
|
0
|
|
|
|
|
0
|
return undef; |
3917
|
|
|
|
|
|
|
} |
3918
|
|
|
|
|
|
|
|
3919
|
|
|
|
|
|
|
# |
3920
|
|
|
|
|
|
|
# HP-15 file test -l $_ |
3921
|
|
|
|
|
|
|
# |
3922
|
|
|
|
|
|
|
sub Ehp15::l_() { |
3923
|
|
|
|
|
|
|
|
3924
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3925
|
0
|
0
|
|
|
|
0
|
return -l _ ? 1 : ''; |
3926
|
|
|
|
|
|
|
} |
3927
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3928
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3929
|
0
|
0
|
|
|
|
0
|
return -l _ ? 1 : ''; |
3930
|
|
|
|
|
|
|
} |
3931
|
|
|
|
|
|
|
else { |
3932
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3933
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3934
|
0
|
|
|
|
|
0
|
my $l = -l $fh; |
3935
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3936
|
0
|
0
|
|
|
|
0
|
return $l ? 1 : ''; |
3937
|
|
|
|
|
|
|
} |
3938
|
|
|
|
|
|
|
} |
3939
|
|
|
|
|
|
|
} |
3940
|
0
|
|
|
|
|
0
|
return undef; |
3941
|
|
|
|
|
|
|
} |
3942
|
|
|
|
|
|
|
|
3943
|
|
|
|
|
|
|
# |
3944
|
|
|
|
|
|
|
# HP-15 file test -p $_ |
3945
|
|
|
|
|
|
|
# |
3946
|
|
|
|
|
|
|
sub Ehp15::p_() { |
3947
|
|
|
|
|
|
|
|
3948
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3949
|
0
|
0
|
|
|
|
0
|
return -p _ ? 1 : ''; |
3950
|
|
|
|
|
|
|
} |
3951
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3952
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3953
|
0
|
0
|
|
|
|
0
|
return -p _ ? 1 : ''; |
3954
|
|
|
|
|
|
|
} |
3955
|
|
|
|
|
|
|
else { |
3956
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3957
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3958
|
0
|
|
|
|
|
0
|
my $p = -p $fh; |
3959
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3960
|
0
|
0
|
|
|
|
0
|
return $p ? 1 : ''; |
3961
|
|
|
|
|
|
|
} |
3962
|
|
|
|
|
|
|
} |
3963
|
|
|
|
|
|
|
} |
3964
|
0
|
|
|
|
|
0
|
return undef; |
3965
|
|
|
|
|
|
|
} |
3966
|
|
|
|
|
|
|
|
3967
|
|
|
|
|
|
|
# |
3968
|
|
|
|
|
|
|
# HP-15 file test -S $_ |
3969
|
|
|
|
|
|
|
# |
3970
|
|
|
|
|
|
|
sub Ehp15::S_() { |
3971
|
|
|
|
|
|
|
|
3972
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3973
|
0
|
0
|
|
|
|
0
|
return -S _ ? 1 : ''; |
3974
|
|
|
|
|
|
|
} |
3975
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
3976
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
3977
|
0
|
0
|
|
|
|
0
|
return -S _ ? 1 : ''; |
3978
|
|
|
|
|
|
|
} |
3979
|
|
|
|
|
|
|
else { |
3980
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
3981
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
3982
|
0
|
|
|
|
|
0
|
my $S = -S $fh; |
3983
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
3984
|
0
|
0
|
|
|
|
0
|
return $S ? 1 : ''; |
3985
|
|
|
|
|
|
|
} |
3986
|
|
|
|
|
|
|
} |
3987
|
|
|
|
|
|
|
} |
3988
|
0
|
|
|
|
|
0
|
return undef; |
3989
|
|
|
|
|
|
|
} |
3990
|
|
|
|
|
|
|
|
3991
|
|
|
|
|
|
|
# |
3992
|
|
|
|
|
|
|
# HP-15 file test -b $_ |
3993
|
|
|
|
|
|
|
# |
3994
|
|
|
|
|
|
|
sub Ehp15::b_() { |
3995
|
|
|
|
|
|
|
|
3996
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
3997
|
0
|
0
|
|
|
|
0
|
return -b _ ? 1 : ''; |
3998
|
|
|
|
|
|
|
} |
3999
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4000
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4001
|
0
|
0
|
|
|
|
0
|
return -b _ ? 1 : ''; |
4002
|
|
|
|
|
|
|
} |
4003
|
|
|
|
|
|
|
else { |
4004
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4005
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4006
|
0
|
|
|
|
|
0
|
my $b = -b $fh; |
4007
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4008
|
0
|
0
|
|
|
|
0
|
return $b ? 1 : ''; |
4009
|
|
|
|
|
|
|
} |
4010
|
|
|
|
|
|
|
} |
4011
|
|
|
|
|
|
|
} |
4012
|
0
|
|
|
|
|
0
|
return undef; |
4013
|
|
|
|
|
|
|
} |
4014
|
|
|
|
|
|
|
|
4015
|
|
|
|
|
|
|
# |
4016
|
|
|
|
|
|
|
# HP-15 file test -c $_ |
4017
|
|
|
|
|
|
|
# |
4018
|
|
|
|
|
|
|
sub Ehp15::c_() { |
4019
|
|
|
|
|
|
|
|
4020
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4021
|
0
|
0
|
|
|
|
0
|
return -c _ ? 1 : ''; |
4022
|
|
|
|
|
|
|
} |
4023
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4024
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4025
|
0
|
0
|
|
|
|
0
|
return -c _ ? 1 : ''; |
4026
|
|
|
|
|
|
|
} |
4027
|
|
|
|
|
|
|
else { |
4028
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4029
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4030
|
0
|
|
|
|
|
0
|
my $c = -c $fh; |
4031
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4032
|
0
|
0
|
|
|
|
0
|
return $c ? 1 : ''; |
4033
|
|
|
|
|
|
|
} |
4034
|
|
|
|
|
|
|
} |
4035
|
|
|
|
|
|
|
} |
4036
|
0
|
|
|
|
|
0
|
return undef; |
4037
|
|
|
|
|
|
|
} |
4038
|
|
|
|
|
|
|
|
4039
|
|
|
|
|
|
|
# |
4040
|
|
|
|
|
|
|
# HP-15 file test -u $_ |
4041
|
|
|
|
|
|
|
# |
4042
|
|
|
|
|
|
|
sub Ehp15::u_() { |
4043
|
|
|
|
|
|
|
|
4044
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4045
|
0
|
0
|
|
|
|
0
|
return -u _ ? 1 : ''; |
4046
|
|
|
|
|
|
|
} |
4047
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4048
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4049
|
0
|
0
|
|
|
|
0
|
return -u _ ? 1 : ''; |
4050
|
|
|
|
|
|
|
} |
4051
|
|
|
|
|
|
|
else { |
4052
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4053
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4054
|
0
|
|
|
|
|
0
|
my $u = -u $fh; |
4055
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4056
|
0
|
0
|
|
|
|
0
|
return $u ? 1 : ''; |
4057
|
|
|
|
|
|
|
} |
4058
|
|
|
|
|
|
|
} |
4059
|
|
|
|
|
|
|
} |
4060
|
0
|
|
|
|
|
0
|
return undef; |
4061
|
|
|
|
|
|
|
} |
4062
|
|
|
|
|
|
|
|
4063
|
|
|
|
|
|
|
# |
4064
|
|
|
|
|
|
|
# HP-15 file test -g $_ |
4065
|
|
|
|
|
|
|
# |
4066
|
|
|
|
|
|
|
sub Ehp15::g_() { |
4067
|
|
|
|
|
|
|
|
4068
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4069
|
0
|
0
|
|
|
|
0
|
return -g _ ? 1 : ''; |
4070
|
|
|
|
|
|
|
} |
4071
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4072
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4073
|
0
|
0
|
|
|
|
0
|
return -g _ ? 1 : ''; |
4074
|
|
|
|
|
|
|
} |
4075
|
|
|
|
|
|
|
else { |
4076
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4077
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4078
|
0
|
|
|
|
|
0
|
my $g = -g $fh; |
4079
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4080
|
0
|
0
|
|
|
|
0
|
return $g ? 1 : ''; |
4081
|
|
|
|
|
|
|
} |
4082
|
|
|
|
|
|
|
} |
4083
|
|
|
|
|
|
|
} |
4084
|
0
|
|
|
|
|
0
|
return undef; |
4085
|
|
|
|
|
|
|
} |
4086
|
|
|
|
|
|
|
|
4087
|
|
|
|
|
|
|
# |
4088
|
|
|
|
|
|
|
# HP-15 file test -k $_ |
4089
|
|
|
|
|
|
|
# |
4090
|
|
|
|
|
|
|
sub Ehp15::k_() { |
4091
|
|
|
|
|
|
|
|
4092
|
0
|
0
|
|
0
|
0
|
0
|
if ($] =~ /^5\.008/oxms) { |
4093
|
0
|
0
|
|
|
|
0
|
return wantarray ? ('',@_) : ''; |
4094
|
|
|
|
|
|
|
} |
4095
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($_,@_) : $_; |
4096
|
|
|
|
|
|
|
} |
4097
|
|
|
|
|
|
|
|
4098
|
|
|
|
|
|
|
# |
4099
|
|
|
|
|
|
|
# HP-15 file test -T $_ |
4100
|
|
|
|
|
|
|
# |
4101
|
|
|
|
|
|
|
sub Ehp15::T_() { |
4102
|
|
|
|
|
|
|
|
4103
|
0
|
|
|
0
|
0
|
0
|
my $T = 1; |
4104
|
|
|
|
|
|
|
|
4105
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
4106
|
0
|
|
|
|
|
0
|
return undef; |
4107
|
|
|
|
|
|
|
} |
4108
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4109
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4110
|
|
|
|
|
|
|
} |
4111
|
|
|
|
|
|
|
else { |
4112
|
0
|
|
|
|
|
0
|
return undef; |
4113
|
|
|
|
|
|
|
} |
4114
|
|
|
|
|
|
|
|
4115
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
4116
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
4117
|
0
|
|
|
|
|
0
|
$T = ''; |
4118
|
|
|
|
|
|
|
} |
4119
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
4120
|
0
|
|
|
|
|
0
|
$T = ''; |
4121
|
|
|
|
|
|
|
} |
4122
|
|
|
|
|
|
|
} |
4123
|
|
|
|
|
|
|
|
4124
|
|
|
|
|
|
|
# 0 byte or eof |
4125
|
|
|
|
|
|
|
else { |
4126
|
0
|
|
|
|
|
0
|
$T = 1; |
4127
|
|
|
|
|
|
|
} |
4128
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -T $fh; |
4129
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4130
|
|
|
|
|
|
|
|
4131
|
0
|
|
|
|
|
0
|
return $T; |
4132
|
|
|
|
|
|
|
} |
4133
|
|
|
|
|
|
|
|
4134
|
|
|
|
|
|
|
# |
4135
|
|
|
|
|
|
|
# HP-15 file test -B $_ |
4136
|
|
|
|
|
|
|
# |
4137
|
|
|
|
|
|
|
sub Ehp15::B_() { |
4138
|
|
|
|
|
|
|
|
4139
|
0
|
|
|
0
|
0
|
0
|
my $B = ''; |
4140
|
|
|
|
|
|
|
|
4141
|
0
|
0
|
0
|
|
|
0
|
if (-d $_ or -d "$_/.") { |
4142
|
0
|
|
|
|
|
0
|
return undef; |
4143
|
|
|
|
|
|
|
} |
4144
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4145
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4146
|
|
|
|
|
|
|
} |
4147
|
|
|
|
|
|
|
else { |
4148
|
0
|
|
|
|
|
0
|
return undef; |
4149
|
|
|
|
|
|
|
} |
4150
|
|
|
|
|
|
|
|
4151
|
0
|
0
|
|
|
|
0
|
if (sysread $fh, my $block, 512) { |
4152
|
0
|
0
|
|
|
|
0
|
if ($block =~ /[\000\377]/oxms) { |
|
|
0
|
|
|
|
|
|
4153
|
0
|
|
|
|
|
0
|
$B = 1; |
4154
|
|
|
|
|
|
|
} |
4155
|
|
|
|
|
|
|
elsif (($block =~ tr/\000-\007\013\016-\032\034-\037\377//) * 10 > CORE::length $block) { |
4156
|
0
|
|
|
|
|
0
|
$B = 1; |
4157
|
|
|
|
|
|
|
} |
4158
|
|
|
|
|
|
|
} |
4159
|
|
|
|
|
|
|
|
4160
|
|
|
|
|
|
|
# 0 byte or eof |
4161
|
|
|
|
|
|
|
else { |
4162
|
0
|
|
|
|
|
0
|
$B = 1; |
4163
|
|
|
|
|
|
|
} |
4164
|
0
|
|
|
|
|
0
|
my $dummy_for_underline_cache = -B $fh; |
4165
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4166
|
|
|
|
|
|
|
|
4167
|
0
|
|
|
|
|
0
|
return $B; |
4168
|
|
|
|
|
|
|
} |
4169
|
|
|
|
|
|
|
|
4170
|
|
|
|
|
|
|
# |
4171
|
|
|
|
|
|
|
# HP-15 file test -M $_ |
4172
|
|
|
|
|
|
|
# |
4173
|
|
|
|
|
|
|
sub Ehp15::M_() { |
4174
|
|
|
|
|
|
|
|
4175
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4176
|
0
|
|
|
|
|
0
|
return -M _; |
4177
|
|
|
|
|
|
|
} |
4178
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4179
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4180
|
0
|
|
|
|
|
0
|
return -M _; |
4181
|
|
|
|
|
|
|
} |
4182
|
|
|
|
|
|
|
else { |
4183
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4184
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4185
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4186
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4187
|
0
|
|
|
|
|
0
|
my $M = ($^T - $mtime) / (24*60*60); |
4188
|
0
|
|
|
|
|
0
|
return $M; |
4189
|
|
|
|
|
|
|
} |
4190
|
|
|
|
|
|
|
} |
4191
|
|
|
|
|
|
|
} |
4192
|
0
|
|
|
|
|
0
|
return undef; |
4193
|
|
|
|
|
|
|
} |
4194
|
|
|
|
|
|
|
|
4195
|
|
|
|
|
|
|
# |
4196
|
|
|
|
|
|
|
# HP-15 file test -A $_ |
4197
|
|
|
|
|
|
|
# |
4198
|
|
|
|
|
|
|
sub Ehp15::A_() { |
4199
|
|
|
|
|
|
|
|
4200
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4201
|
0
|
|
|
|
|
0
|
return -A _; |
4202
|
|
|
|
|
|
|
} |
4203
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4204
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4205
|
0
|
|
|
|
|
0
|
return -A _; |
4206
|
|
|
|
|
|
|
} |
4207
|
|
|
|
|
|
|
else { |
4208
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4209
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4210
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4211
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4212
|
0
|
|
|
|
|
0
|
my $A = ($^T - $atime) / (24*60*60); |
4213
|
0
|
|
|
|
|
0
|
return $A; |
4214
|
|
|
|
|
|
|
} |
4215
|
|
|
|
|
|
|
} |
4216
|
|
|
|
|
|
|
} |
4217
|
0
|
|
|
|
|
0
|
return undef; |
4218
|
|
|
|
|
|
|
} |
4219
|
|
|
|
|
|
|
|
4220
|
|
|
|
|
|
|
# |
4221
|
|
|
|
|
|
|
# HP-15 file test -C $_ |
4222
|
|
|
|
|
|
|
# |
4223
|
|
|
|
|
|
|
sub Ehp15::C_() { |
4224
|
|
|
|
|
|
|
|
4225
|
0
|
0
|
|
0
|
0
|
0
|
if (-e $_) { |
|
|
0
|
|
|
|
|
|
4226
|
0
|
|
|
|
|
0
|
return -C _; |
4227
|
|
|
|
|
|
|
} |
4228
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4229
|
0
|
0
|
|
|
|
0
|
if (-d "$_/.") { |
4230
|
0
|
|
|
|
|
0
|
return -C _; |
4231
|
|
|
|
|
|
|
} |
4232
|
|
|
|
|
|
|
else { |
4233
|
0
|
|
|
|
|
0
|
my $fh = gensym(); |
4234
|
0
|
0
|
|
|
|
0
|
if (_open_r($fh, $_)) { |
4235
|
0
|
|
|
|
|
0
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = CORE::stat $fh; |
4236
|
0
|
0
|
|
|
|
0
|
close($fh) or die "Can't close file: $_: $!"; |
4237
|
0
|
|
|
|
|
0
|
my $C = ($^T - $ctime) / (24*60*60); |
4238
|
0
|
|
|
|
|
0
|
return $C; |
4239
|
|
|
|
|
|
|
} |
4240
|
|
|
|
|
|
|
} |
4241
|
|
|
|
|
|
|
} |
4242
|
0
|
|
|
|
|
0
|
return undef; |
4243
|
|
|
|
|
|
|
} |
4244
|
|
|
|
|
|
|
|
4245
|
|
|
|
|
|
|
# |
4246
|
|
|
|
|
|
|
# HP-15 path globbing (with parameter) |
4247
|
|
|
|
|
|
|
# |
4248
|
|
|
|
|
|
|
sub Ehp15::glob($) { |
4249
|
|
|
|
|
|
|
|
4250
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
4251
|
0
|
|
|
|
|
0
|
my @glob = _DOS_like_glob(@_); |
4252
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
4253
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4254
|
|
|
|
|
|
|
} |
4255
|
0
|
|
|
|
|
0
|
return @glob; |
4256
|
|
|
|
|
|
|
} |
4257
|
|
|
|
|
|
|
else { |
4258
|
0
|
|
|
|
|
0
|
my $glob = _DOS_like_glob(@_); |
4259
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4260
|
0
|
|
|
|
|
0
|
return $glob; |
4261
|
|
|
|
|
|
|
} |
4262
|
|
|
|
|
|
|
} |
4263
|
|
|
|
|
|
|
|
4264
|
|
|
|
|
|
|
# |
4265
|
|
|
|
|
|
|
# HP-15 path globbing (without parameter) |
4266
|
|
|
|
|
|
|
# |
4267
|
|
|
|
|
|
|
sub Ehp15::glob_() { |
4268
|
|
|
|
|
|
|
|
4269
|
0
|
0
|
|
0
|
0
|
0
|
if (wantarray) { |
4270
|
0
|
|
|
|
|
0
|
my @glob = _DOS_like_glob(); |
4271
|
0
|
|
|
|
|
0
|
for my $glob (@glob) { |
4272
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4273
|
|
|
|
|
|
|
} |
4274
|
0
|
|
|
|
|
0
|
return @glob; |
4275
|
|
|
|
|
|
|
} |
4276
|
|
|
|
|
|
|
else { |
4277
|
0
|
|
|
|
|
0
|
my $glob = _DOS_like_glob(); |
4278
|
0
|
|
|
|
|
0
|
$glob =~ s{ \A (?:\./)+ }{}oxms; |
4279
|
0
|
|
|
|
|
0
|
return $glob; |
4280
|
|
|
|
|
|
|
} |
4281
|
|
|
|
|
|
|
} |
4282
|
|
|
|
|
|
|
|
4283
|
|
|
|
|
|
|
# |
4284
|
|
|
|
|
|
|
# HP-15 path globbing via File::DosGlob 1.10 |
4285
|
|
|
|
|
|
|
# |
4286
|
|
|
|
|
|
|
# Often I confuse "_dosglob" and "_doglob". |
4287
|
|
|
|
|
|
|
# So, I renamed "_dosglob" to "_DOS_like_glob". |
4288
|
|
|
|
|
|
|
# |
4289
|
|
|
|
|
|
|
my %iter; |
4290
|
|
|
|
|
|
|
my %entries; |
4291
|
|
|
|
|
|
|
sub _DOS_like_glob { |
4292
|
|
|
|
|
|
|
|
4293
|
|
|
|
|
|
|
# context (keyed by second cxix argument provided by core) |
4294
|
0
|
|
|
0
|
|
0
|
my($expr,$cxix) = @_; |
4295
|
|
|
|
|
|
|
|
4296
|
|
|
|
|
|
|
# glob without args defaults to $_ |
4297
|
0
|
0
|
|
|
|
0
|
$expr = $_ if not defined $expr; |
4298
|
|
|
|
|
|
|
|
4299
|
|
|
|
|
|
|
# represents the current user's home directory |
4300
|
|
|
|
|
|
|
# |
4301
|
|
|
|
|
|
|
# 7.3. Expanding Tildes in Filenames |
4302
|
|
|
|
|
|
|
# in Chapter 7. File Access |
4303
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
4304
|
|
|
|
|
|
|
# |
4305
|
|
|
|
|
|
|
# and File::HomeDir, File::HomeDir::Windows module |
4306
|
|
|
|
|
|
|
|
4307
|
|
|
|
|
|
|
# DOS-like system |
4308
|
0
|
0
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
4309
|
0
|
|
|
|
|
0
|
$expr =~ s{ \A ~ (?= [^/\\] ) } |
|
0
|
|
|
|
|
0
|
|
4310
|
|
|
|
|
|
|
{ my_home_MSWin32() }oxmse; |
4311
|
|
|
|
|
|
|
} |
4312
|
|
|
|
|
|
|
|
4313
|
|
|
|
|
|
|
# UNIX-like system |
4314
|
0
|
0
|
0
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
4315
|
|
|
|
|
|
|
$expr =~ s{ \A ~ ( (?:[^\x80-\xA0\xE0-\xFE/]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])* ) } |
4316
|
|
|
|
|
|
|
{ $1 ? (CORE::eval(q{(getpwnam($1))[7]})||my_home()) : my_home() }oxmse; |
4317
|
|
|
|
|
|
|
} |
4318
|
0
|
0
|
|
|
|
0
|
|
4319
|
0
|
0
|
|
|
|
0
|
# assume global context if not provided one |
4320
|
|
|
|
|
|
|
$cxix = '_G_' if not defined $cxix; |
4321
|
|
|
|
|
|
|
$iter{$cxix} = 0 if not exists $iter{$cxix}; |
4322
|
0
|
0
|
|
|
|
0
|
|
4323
|
0
|
|
|
|
|
0
|
# if we're just beginning, do it all first |
4324
|
|
|
|
|
|
|
if ($iter{$cxix} == 0) { |
4325
|
|
|
|
|
|
|
$entries{$cxix} = [ _do_glob(1, _parse_line($expr)) ]; |
4326
|
|
|
|
|
|
|
} |
4327
|
0
|
0
|
|
|
|
0
|
|
4328
|
0
|
|
|
|
|
0
|
# chuck it all out, quick or slow |
4329
|
0
|
|
|
|
|
0
|
if (wantarray) { |
|
0
|
|
|
|
|
0
|
|
4330
|
|
|
|
|
|
|
delete $iter{$cxix}; |
4331
|
|
|
|
|
|
|
return @{delete $entries{$cxix}}; |
4332
|
0
|
0
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
4333
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
4334
|
|
|
|
|
|
|
if ($iter{$cxix} = scalar @{$entries{$cxix}}) { |
4335
|
|
|
|
|
|
|
return shift @{$entries{$cxix}}; |
4336
|
|
|
|
|
|
|
} |
4337
|
0
|
|
|
|
|
0
|
else { |
4338
|
0
|
|
|
|
|
0
|
# return undef for EOL |
4339
|
0
|
|
|
|
|
0
|
delete $iter{$cxix}; |
4340
|
|
|
|
|
|
|
delete $entries{$cxix}; |
4341
|
|
|
|
|
|
|
return undef; |
4342
|
|
|
|
|
|
|
} |
4343
|
|
|
|
|
|
|
} |
4344
|
|
|
|
|
|
|
} |
4345
|
|
|
|
|
|
|
|
4346
|
|
|
|
|
|
|
# |
4347
|
|
|
|
|
|
|
# HP-15 path globbing subroutine |
4348
|
|
|
|
|
|
|
# |
4349
|
0
|
|
|
0
|
|
0
|
sub _do_glob { |
4350
|
0
|
|
|
|
|
0
|
|
4351
|
0
|
|
|
|
|
0
|
my($cond,@expr) = @_; |
4352
|
|
|
|
|
|
|
my @glob = (); |
4353
|
|
|
|
|
|
|
my $fix_drive_relative_paths = 0; |
4354
|
0
|
|
|
|
|
0
|
|
4355
|
0
|
0
|
|
|
|
0
|
OUTER: |
4356
|
0
|
0
|
|
|
|
0
|
for my $expr (@expr) { |
4357
|
|
|
|
|
|
|
next OUTER if not defined $expr; |
4358
|
0
|
|
|
|
|
0
|
next OUTER if $expr eq ''; |
4359
|
0
|
|
|
|
|
0
|
|
4360
|
0
|
|
|
|
|
0
|
my @matched = (); |
4361
|
0
|
|
|
|
|
0
|
my @globdir = (); |
4362
|
0
|
|
|
|
|
0
|
my $head = '.'; |
4363
|
|
|
|
|
|
|
my $pathsep = '/'; |
4364
|
|
|
|
|
|
|
my $tail; |
4365
|
0
|
0
|
|
|
|
0
|
|
4366
|
0
|
|
|
|
|
0
|
# if argument is within quotes strip em and do no globbing |
4367
|
0
|
0
|
|
|
|
0
|
if ($expr =~ /\A " ((?:$q_char)*?) " \z/oxms) { |
4368
|
0
|
0
|
|
|
|
0
|
$expr = $1; |
4369
|
0
|
|
|
|
|
0
|
if ($cond eq 'd') { |
4370
|
|
|
|
|
|
|
if (Ehp15::d $expr) { |
4371
|
|
|
|
|
|
|
push @glob, $expr; |
4372
|
|
|
|
|
|
|
} |
4373
|
0
|
0
|
|
|
|
0
|
} |
4374
|
0
|
|
|
|
|
0
|
else { |
4375
|
|
|
|
|
|
|
if (Ehp15::e $expr) { |
4376
|
|
|
|
|
|
|
push @glob, $expr; |
4377
|
0
|
|
|
|
|
0
|
} |
4378
|
|
|
|
|
|
|
} |
4379
|
|
|
|
|
|
|
next OUTER; |
4380
|
|
|
|
|
|
|
} |
4381
|
|
|
|
|
|
|
|
4382
|
0
|
0
|
|
|
|
0
|
# wildcards with a drive prefix such as h:*.pm must be changed |
4383
|
0
|
0
|
|
|
|
0
|
# to h:./*.pm to expand correctly |
4384
|
0
|
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
4385
|
|
|
|
|
|
|
if ($expr =~ s# \A ((?:[A-Za-z]:)?) ([^\x80-\xA0\xE0-\xFE/\\]|[\x80-\xA0\xE0-\xFE][\x00-\xFF]) #$1./$2#oxms) { |
4386
|
|
|
|
|
|
|
$fix_drive_relative_paths = 1; |
4387
|
|
|
|
|
|
|
} |
4388
|
0
|
0
|
|
|
|
0
|
} |
4389
|
0
|
0
|
|
|
|
0
|
|
4390
|
0
|
|
|
|
|
0
|
if (($head, $tail) = _parse_path($expr,$pathsep)) { |
4391
|
0
|
|
|
|
|
0
|
if ($tail eq '') { |
4392
|
|
|
|
|
|
|
push @glob, $expr; |
4393
|
0
|
0
|
|
|
|
0
|
next OUTER; |
4394
|
0
|
0
|
|
|
|
0
|
} |
4395
|
0
|
|
|
|
|
0
|
if ($head =~ / \A (?:$q_char)*? [*?] /oxms) { |
|
0
|
|
|
|
|
0
|
|
4396
|
0
|
|
|
|
|
0
|
if (@globdir = _do_glob('d', $head)) { |
4397
|
|
|
|
|
|
|
push @glob, _do_glob($cond, map {"$_$pathsep$tail"} @globdir); |
4398
|
|
|
|
|
|
|
next OUTER; |
4399
|
0
|
0
|
0
|
|
|
0
|
} |
4400
|
0
|
|
|
|
|
0
|
} |
4401
|
|
|
|
|
|
|
if ($head eq '' or $head =~ /\A [A-Za-z]: \z/oxms) { |
4402
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
4403
|
|
|
|
|
|
|
} |
4404
|
|
|
|
|
|
|
$expr = $tail; |
4405
|
|
|
|
|
|
|
} |
4406
|
0
|
0
|
|
|
|
0
|
|
4407
|
0
|
0
|
|
|
|
0
|
# If file component has no wildcards, we can avoid opendir |
4408
|
0
|
|
|
|
|
0
|
if ($expr !~ / \A (?:$q_char)*? [*?] /oxms) { |
4409
|
|
|
|
|
|
|
if ($head eq '.') { |
4410
|
0
|
0
|
0
|
|
|
0
|
$head = ''; |
4411
|
0
|
|
|
|
|
0
|
} |
4412
|
|
|
|
|
|
|
if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) { |
4413
|
0
|
|
|
|
|
0
|
$head .= $pathsep; |
4414
|
0
|
0
|
|
|
|
0
|
} |
4415
|
0
|
0
|
|
|
|
0
|
$head .= $expr; |
4416
|
0
|
|
|
|
|
0
|
if ($cond eq 'd') { |
4417
|
|
|
|
|
|
|
if (Ehp15::d $head) { |
4418
|
|
|
|
|
|
|
push @glob, $head; |
4419
|
|
|
|
|
|
|
} |
4420
|
0
|
0
|
|
|
|
0
|
} |
4421
|
0
|
|
|
|
|
0
|
else { |
4422
|
|
|
|
|
|
|
if (Ehp15::e $head) { |
4423
|
|
|
|
|
|
|
push @glob, $head; |
4424
|
0
|
|
|
|
|
0
|
} |
4425
|
|
|
|
|
|
|
} |
4426
|
0
|
0
|
|
|
|
0
|
next OUTER; |
4427
|
0
|
|
|
|
|
0
|
} |
4428
|
0
|
|
|
|
|
0
|
Ehp15::opendir(*DIR, $head) or next OUTER; |
4429
|
|
|
|
|
|
|
my @leaf = readdir DIR; |
4430
|
0
|
0
|
|
|
|
0
|
closedir DIR; |
4431
|
0
|
|
|
|
|
0
|
|
4432
|
|
|
|
|
|
|
if ($head eq '.') { |
4433
|
0
|
0
|
0
|
|
|
0
|
$head = ''; |
4434
|
0
|
|
|
|
|
0
|
} |
4435
|
|
|
|
|
|
|
if ($head ne '' and ($head =~ / \G ($q_char) /oxmsg)[-1] ne $pathsep) { |
4436
|
|
|
|
|
|
|
$head .= $pathsep; |
4437
|
0
|
|
|
|
|
0
|
} |
4438
|
0
|
|
|
|
|
0
|
|
4439
|
0
|
|
|
|
|
0
|
my $pattern = ''; |
4440
|
|
|
|
|
|
|
while ($expr =~ / \G ($q_char) /oxgc) { |
4441
|
|
|
|
|
|
|
my $char = $1; |
4442
|
|
|
|
|
|
|
|
4443
|
|
|
|
|
|
|
# 6.9. Matching Shell Globs as Regular Expressions |
4444
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
4445
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
4446
|
0
|
0
|
|
|
|
0
|
# (and so on) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4447
|
0
|
|
|
|
|
0
|
|
4448
|
|
|
|
|
|
|
if ($char eq '*') { |
4449
|
|
|
|
|
|
|
$pattern .= "(?:$your_char)*", |
4450
|
0
|
|
|
|
|
0
|
} |
4451
|
|
|
|
|
|
|
elsif ($char eq '?') { |
4452
|
|
|
|
|
|
|
$pattern .= "(?:$your_char)?", # DOS style |
4453
|
|
|
|
|
|
|
# $pattern .= "(?:$your_char)", # UNIX style |
4454
|
0
|
|
|
|
|
0
|
} |
4455
|
|
|
|
|
|
|
elsif ((my $fc = Ehp15::fc($char)) ne $char) { |
4456
|
|
|
|
|
|
|
$pattern .= $fc; |
4457
|
0
|
|
|
|
|
0
|
} |
4458
|
|
|
|
|
|
|
else { |
4459
|
|
|
|
|
|
|
$pattern .= quotemeta $char; |
4460
|
0
|
|
|
0
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
4461
|
|
|
|
|
|
|
} |
4462
|
|
|
|
|
|
|
my $matchsub = sub { Ehp15::fc($_[0]) =~ /\A $pattern \z/xms }; |
4463
|
|
|
|
|
|
|
|
4464
|
|
|
|
|
|
|
# if ($@) { |
4465
|
|
|
|
|
|
|
# print STDERR "$0: $@\n"; |
4466
|
|
|
|
|
|
|
# next OUTER; |
4467
|
|
|
|
|
|
|
# } |
4468
|
0
|
|
|
|
|
0
|
|
4469
|
0
|
0
|
0
|
|
|
0
|
INNER: |
4470
|
0
|
|
|
|
|
0
|
for my $leaf (@leaf) { |
4471
|
|
|
|
|
|
|
if ($leaf eq '.' or $leaf eq '..') { |
4472
|
0
|
0
|
0
|
|
|
0
|
next INNER; |
4473
|
0
|
|
|
|
|
0
|
} |
4474
|
|
|
|
|
|
|
if ($cond eq 'd' and not Ehp15::d "$head$leaf") { |
4475
|
|
|
|
|
|
|
next INNER; |
4476
|
0
|
0
|
|
|
|
0
|
} |
4477
|
0
|
|
|
|
|
0
|
|
4478
|
0
|
|
|
|
|
0
|
if (&$matchsub($leaf)) { |
4479
|
|
|
|
|
|
|
push @matched, "$head$leaf"; |
4480
|
|
|
|
|
|
|
next INNER; |
4481
|
|
|
|
|
|
|
} |
4482
|
|
|
|
|
|
|
|
4483
|
|
|
|
|
|
|
# [DOS compatibility special case] |
4484
|
0
|
0
|
0
|
|
|
0
|
# Failed, add a trailing dot and try again, but only... |
|
|
|
0
|
|
|
|
|
4485
|
|
|
|
|
|
|
|
4486
|
|
|
|
|
|
|
if (Ehp15::index($leaf,'.') == -1 and # if name does not have a dot in it *and* |
4487
|
|
|
|
|
|
|
CORE::length($leaf) <= 8 and # name is shorter than or equal to 8 chars *and* |
4488
|
0
|
0
|
|
|
|
0
|
Ehp15::index($pattern,'\\.') != -1 # pattern has a dot. |
4489
|
0
|
|
|
|
|
0
|
) { |
4490
|
0
|
|
|
|
|
0
|
if (&$matchsub("$leaf.")) { |
4491
|
|
|
|
|
|
|
push @matched, "$head$leaf"; |
4492
|
|
|
|
|
|
|
next INNER; |
4493
|
|
|
|
|
|
|
} |
4494
|
0
|
0
|
|
|
|
0
|
} |
4495
|
0
|
|
|
|
|
0
|
} |
4496
|
|
|
|
|
|
|
if (@matched) { |
4497
|
|
|
|
|
|
|
push @glob, @matched; |
4498
|
0
|
0
|
|
|
|
0
|
} |
4499
|
0
|
|
|
|
|
0
|
} |
4500
|
0
|
|
|
|
|
0
|
if ($fix_drive_relative_paths) { |
4501
|
|
|
|
|
|
|
for my $glob (@glob) { |
4502
|
|
|
|
|
|
|
$glob =~ s# \A ([A-Za-z]:) \./ #$1#oxms; |
4503
|
0
|
|
|
|
|
0
|
} |
4504
|
|
|
|
|
|
|
} |
4505
|
|
|
|
|
|
|
return @glob; |
4506
|
|
|
|
|
|
|
} |
4507
|
|
|
|
|
|
|
|
4508
|
|
|
|
|
|
|
# |
4509
|
|
|
|
|
|
|
# HP-15 parse line |
4510
|
|
|
|
|
|
|
# |
4511
|
0
|
|
|
0
|
|
0
|
sub _parse_line { |
4512
|
|
|
|
|
|
|
|
4513
|
0
|
|
|
|
|
0
|
my($line) = @_; |
4514
|
0
|
|
|
|
|
0
|
|
4515
|
0
|
|
|
|
|
0
|
$line .= ' '; |
4516
|
|
|
|
|
|
|
my @piece = (); |
4517
|
|
|
|
|
|
|
while ($line =~ / |
4518
|
|
|
|
|
|
|
" ( (?>(?: [^\x80-\xA0\xE0-\xFE"] |[\x80-\xA0\xE0-\xFE][\x00-\xFF] )* ) ) " (?>\s+) | |
4519
|
|
|
|
|
|
|
( (?>(?: [^\x80-\xA0\xE0-\xFE"\s]|[\x80-\xA0\xE0-\xFE][\x00-\xFF] )* ) ) (?>\s+) |
4520
|
0
|
0
|
|
|
|
0
|
/oxmsg |
4521
|
|
|
|
|
|
|
) { |
4522
|
0
|
|
|
|
|
0
|
push @piece, defined($1) ? $1 : $2; |
4523
|
|
|
|
|
|
|
} |
4524
|
|
|
|
|
|
|
return @piece; |
4525
|
|
|
|
|
|
|
} |
4526
|
|
|
|
|
|
|
|
4527
|
|
|
|
|
|
|
# |
4528
|
|
|
|
|
|
|
# HP-15 parse path |
4529
|
|
|
|
|
|
|
# |
4530
|
0
|
|
|
0
|
|
0
|
sub _parse_path { |
4531
|
|
|
|
|
|
|
|
4532
|
0
|
|
|
|
|
0
|
my($path,$pathsep) = @_; |
4533
|
0
|
|
|
|
|
0
|
|
4534
|
0
|
|
|
|
|
0
|
$path .= '/'; |
4535
|
|
|
|
|
|
|
my @subpath = (); |
4536
|
|
|
|
|
|
|
while ($path =~ / |
4537
|
|
|
|
|
|
|
((?: [^\x80-\xA0\xE0-\xFE\/\\]|[\x80-\xA0\xE0-\xFE][\x00-\xFF] )+?) [\/\\] |
4538
|
0
|
|
|
|
|
0
|
/oxmsg |
4539
|
|
|
|
|
|
|
) { |
4540
|
|
|
|
|
|
|
push @subpath, $1; |
4541
|
0
|
|
|
|
|
0
|
} |
4542
|
0
|
|
|
|
|
0
|
|
4543
|
0
|
|
|
|
|
0
|
my $tail = pop @subpath; |
4544
|
|
|
|
|
|
|
my $head = join $pathsep, @subpath; |
4545
|
|
|
|
|
|
|
return $head, $tail; |
4546
|
|
|
|
|
|
|
} |
4547
|
|
|
|
|
|
|
|
4548
|
|
|
|
|
|
|
# |
4549
|
|
|
|
|
|
|
# via File::HomeDir::Windows 1.00 |
4550
|
|
|
|
|
|
|
# |
4551
|
|
|
|
|
|
|
sub my_home_MSWin32 { |
4552
|
|
|
|
|
|
|
|
4553
|
|
|
|
|
|
|
# A lot of unix people and unix-derived tools rely on |
4554
|
0
|
0
|
0
|
0
|
0
|
0
|
# the ability to overload HOME. We will support it too |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
4555
|
0
|
|
|
|
|
0
|
# so that they can replace raw HOME calls with File::HomeDir. |
4556
|
|
|
|
|
|
|
if (exists $ENV{'HOME'} and $ENV{'HOME'}) { |
4557
|
|
|
|
|
|
|
return $ENV{'HOME'}; |
4558
|
|
|
|
|
|
|
} |
4559
|
|
|
|
|
|
|
|
4560
|
0
|
|
|
|
|
0
|
# Do we have a user profile? |
4561
|
|
|
|
|
|
|
elsif (exists $ENV{'USERPROFILE'} and $ENV{'USERPROFILE'}) { |
4562
|
|
|
|
|
|
|
return $ENV{'USERPROFILE'}; |
4563
|
|
|
|
|
|
|
} |
4564
|
|
|
|
|
|
|
|
4565
|
0
|
|
|
|
|
0
|
# Some Windows use something like $ENV{'HOME'} |
4566
|
|
|
|
|
|
|
elsif (exists $ENV{'HOMEDRIVE'} and exists $ENV{'HOMEPATH'} and $ENV{'HOMEDRIVE'} and $ENV{'HOMEPATH'}) { |
4567
|
|
|
|
|
|
|
return join '', $ENV{'HOMEDRIVE'}, $ENV{'HOMEPATH'}; |
4568
|
0
|
|
|
|
|
0
|
} |
4569
|
|
|
|
|
|
|
|
4570
|
|
|
|
|
|
|
return undef; |
4571
|
|
|
|
|
|
|
} |
4572
|
|
|
|
|
|
|
|
4573
|
|
|
|
|
|
|
# |
4574
|
|
|
|
|
|
|
# via File::HomeDir::Unix 1.00 |
4575
|
0
|
|
|
0
|
0
|
0
|
# |
4576
|
|
|
|
|
|
|
sub my_home { |
4577
|
0
|
0
|
0
|
|
|
0
|
my $home; |
|
|
0
|
0
|
|
|
|
|
4578
|
0
|
|
|
|
|
0
|
|
4579
|
|
|
|
|
|
|
if (exists $ENV{'HOME'} and defined $ENV{'HOME'}) { |
4580
|
|
|
|
|
|
|
$home = $ENV{'HOME'}; |
4581
|
|
|
|
|
|
|
} |
4582
|
|
|
|
|
|
|
|
4583
|
|
|
|
|
|
|
# This is from the original code, but I'm guessing |
4584
|
0
|
|
|
|
|
0
|
# it means "login directory" and exists on some Unixes. |
4585
|
|
|
|
|
|
|
elsif (exists $ENV{'LOGDIR'} and $ENV{'LOGDIR'}) { |
4586
|
|
|
|
|
|
|
$home = $ENV{'LOGDIR'}; |
4587
|
|
|
|
|
|
|
} |
4588
|
|
|
|
|
|
|
|
4589
|
|
|
|
|
|
|
### More-desperate methods |
4590
|
|
|
|
|
|
|
|
4591
|
0
|
|
|
|
|
0
|
# Light desperation on any (Unixish) platform |
4592
|
|
|
|
|
|
|
else { |
4593
|
|
|
|
|
|
|
$home = CORE::eval q{ (getpwuid($<))[7] }; |
4594
|
|
|
|
|
|
|
} |
4595
|
|
|
|
|
|
|
|
4596
|
0
|
0
|
0
|
|
|
0
|
# On Unix in general, a non-existant home means "no home" |
4597
|
0
|
|
|
|
|
0
|
# For example, "nobody"-like users might use /nonexistant |
4598
|
|
|
|
|
|
|
if (defined $home and ! Ehp15::d($home)) { |
4599
|
0
|
|
|
|
|
0
|
$home = undef; |
4600
|
|
|
|
|
|
|
} |
4601
|
|
|
|
|
|
|
return $home; |
4602
|
|
|
|
|
|
|
} |
4603
|
|
|
|
|
|
|
|
4604
|
|
|
|
|
|
|
# |
4605
|
|
|
|
|
|
|
# HP-15 file lstat (with parameter) |
4606
|
|
|
|
|
|
|
# |
4607
|
0
|
0
|
|
0
|
0
|
0
|
sub Ehp15::lstat(*) { |
4608
|
|
|
|
|
|
|
|
4609
|
0
|
0
|
|
|
|
0
|
local $_ = shift if @_; |
|
|
0
|
|
|
|
|
|
4610
|
0
|
|
|
|
|
0
|
|
4611
|
|
|
|
|
|
|
if (-e $_) { |
4612
|
|
|
|
|
|
|
return CORE::lstat _; |
4613
|
|
|
|
|
|
|
} |
4614
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4615
|
|
|
|
|
|
|
|
4616
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Ehp15::lstat() |
4617
|
|
|
|
|
|
|
# on Windows opens the file for the path which has 5c at end. |
4618
|
0
|
|
|
|
|
0
|
# (and so on) |
4619
|
0
|
0
|
|
|
|
0
|
|
4620
|
0
|
0
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4621
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4622
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
4623
|
0
|
|
|
|
|
0
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4624
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4625
|
|
|
|
|
|
|
return @stat; |
4626
|
0
|
|
|
|
|
0
|
} |
4627
|
0
|
0
|
|
|
|
0
|
else { |
4628
|
0
|
|
|
|
|
0
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4629
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4630
|
|
|
|
|
|
|
return $stat; |
4631
|
|
|
|
|
|
|
} |
4632
|
0
|
0
|
|
|
|
0
|
} |
4633
|
|
|
|
|
|
|
} |
4634
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4635
|
|
|
|
|
|
|
} |
4636
|
|
|
|
|
|
|
|
4637
|
|
|
|
|
|
|
# |
4638
|
|
|
|
|
|
|
# HP-15 file lstat (without parameter) |
4639
|
|
|
|
|
|
|
# |
4640
|
0
|
0
|
|
0
|
0
|
0
|
sub Ehp15::lstat_() { |
|
|
0
|
|
|
|
|
|
4641
|
0
|
|
|
|
|
0
|
|
4642
|
|
|
|
|
|
|
if (-e $_) { |
4643
|
|
|
|
|
|
|
return CORE::lstat _; |
4644
|
0
|
|
|
|
|
0
|
} |
4645
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
4646
|
0
|
0
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4647
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4648
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
4649
|
0
|
|
|
|
|
0
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4650
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4651
|
|
|
|
|
|
|
return @stat; |
4652
|
0
|
|
|
|
|
0
|
} |
4653
|
0
|
0
|
|
|
|
0
|
else { |
4654
|
0
|
|
|
|
|
0
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; # not CORE::lstat |
4655
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4656
|
|
|
|
|
|
|
return $stat; |
4657
|
|
|
|
|
|
|
} |
4658
|
0
|
0
|
|
|
|
0
|
} |
4659
|
|
|
|
|
|
|
} |
4660
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4661
|
|
|
|
|
|
|
} |
4662
|
|
|
|
|
|
|
|
4663
|
|
|
|
|
|
|
# |
4664
|
|
|
|
|
|
|
# HP-15 path opendir |
4665
|
|
|
|
|
|
|
# |
4666
|
0
|
|
|
0
|
0
|
0
|
sub Ehp15::opendir(*$) { |
4667
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
4668
|
0
|
|
|
|
|
0
|
my $dh = qualify_to_ref $_[0]; |
4669
|
|
|
|
|
|
|
if (CORE::opendir $dh, $_[1]) { |
4670
|
|
|
|
|
|
|
return 1; |
4671
|
0
|
0
|
|
|
|
0
|
} |
4672
|
0
|
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_[1])) { |
4673
|
|
|
|
|
|
|
if (CORE::opendir $dh, "$_[1]/.") { |
4674
|
|
|
|
|
|
|
return 1; |
4675
|
0
|
|
|
|
|
0
|
} |
4676
|
|
|
|
|
|
|
} |
4677
|
|
|
|
|
|
|
return undef; |
4678
|
|
|
|
|
|
|
} |
4679
|
|
|
|
|
|
|
|
4680
|
|
|
|
|
|
|
# |
4681
|
|
|
|
|
|
|
# HP-15 file stat (with parameter) |
4682
|
|
|
|
|
|
|
# |
4683
|
0
|
50
|
|
384
|
0
|
0
|
sub Ehp15::stat(*) { |
4684
|
|
|
|
|
|
|
|
4685
|
384
|
|
|
|
|
2362
|
local $_ = shift if @_; |
4686
|
384
|
50
|
|
|
|
2586
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4687
|
384
|
|
|
|
|
13516
|
my $fh = qualify_to_ref $_; |
4688
|
|
|
|
|
|
|
if (defined fileno $fh) { |
4689
|
|
|
|
|
|
|
return CORE::stat $fh; |
4690
|
0
|
|
|
|
|
0
|
} |
4691
|
|
|
|
|
|
|
elsif (-e $_) { |
4692
|
|
|
|
|
|
|
return CORE::stat _; |
4693
|
|
|
|
|
|
|
} |
4694
|
|
|
|
|
|
|
elsif (_MSWin32_5Cended_path($_)) { |
4695
|
|
|
|
|
|
|
|
4696
|
|
|
|
|
|
|
# Even if ${^WIN32_SLOPPY_STAT} is set to a true value, Ehp15::stat() |
4697
|
|
|
|
|
|
|
# on Windows opens the file for the path which has 5c at end. |
4698
|
384
|
|
|
|
|
2969
|
# (and so on) |
4699
|
0
|
0
|
|
|
|
0
|
|
4700
|
0
|
0
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4701
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4702
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
4703
|
0
|
|
|
|
|
0
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
4704
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4705
|
|
|
|
|
|
|
return @stat; |
4706
|
0
|
|
|
|
|
0
|
} |
4707
|
0
|
0
|
|
|
|
0
|
else { |
4708
|
0
|
|
|
|
|
0
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
4709
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4710
|
|
|
|
|
|
|
return $stat; |
4711
|
|
|
|
|
|
|
} |
4712
|
0
|
0
|
|
|
|
0
|
} |
4713
|
|
|
|
|
|
|
} |
4714
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4715
|
|
|
|
|
|
|
} |
4716
|
|
|
|
|
|
|
|
4717
|
|
|
|
|
|
|
# |
4718
|
|
|
|
|
|
|
# HP-15 file stat (without parameter) |
4719
|
|
|
|
|
|
|
# |
4720
|
0
|
|
|
0
|
0
|
0
|
sub Ehp15::stat_() { |
4721
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4722
|
0
|
|
|
|
|
0
|
my $fh = qualify_to_ref $_; |
4723
|
|
|
|
|
|
|
if (defined fileno $fh) { |
4724
|
|
|
|
|
|
|
return CORE::stat $fh; |
4725
|
0
|
|
|
|
|
0
|
} |
4726
|
|
|
|
|
|
|
elsif (-e $_) { |
4727
|
|
|
|
|
|
|
return CORE::stat _; |
4728
|
0
|
|
|
|
|
0
|
} |
4729
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
4730
|
0
|
0
|
|
|
|
0
|
local *MUST_BE_BAREWORD_AT_HERE; |
4731
|
0
|
|
|
|
|
0
|
if (CORE::open(MUST_BE_BAREWORD_AT_HERE, $_)) { |
4732
|
0
|
0
|
|
|
|
0
|
if (wantarray) { |
4733
|
0
|
|
|
|
|
0
|
my @stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
4734
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4735
|
|
|
|
|
|
|
return @stat; |
4736
|
0
|
|
|
|
|
0
|
} |
4737
|
0
|
0
|
|
|
|
0
|
else { |
4738
|
0
|
|
|
|
|
0
|
my $stat = CORE::stat MUST_BE_BAREWORD_AT_HERE; |
4739
|
|
|
|
|
|
|
close(MUST_BE_BAREWORD_AT_HERE) or die "Can't close file: $_: $!"; |
4740
|
|
|
|
|
|
|
return $stat; |
4741
|
|
|
|
|
|
|
} |
4742
|
0
|
0
|
|
|
|
0
|
} |
4743
|
|
|
|
|
|
|
} |
4744
|
|
|
|
|
|
|
return wantarray ? () : undef; |
4745
|
|
|
|
|
|
|
} |
4746
|
|
|
|
|
|
|
|
4747
|
|
|
|
|
|
|
# |
4748
|
|
|
|
|
|
|
# HP-15 path unlink |
4749
|
|
|
|
|
|
|
# |
4750
|
0
|
0
|
|
0
|
0
|
0
|
sub Ehp15::unlink(@) { |
4751
|
|
|
|
|
|
|
|
4752
|
0
|
|
|
|
|
0
|
local @_ = ($_) unless @_; |
4753
|
0
|
|
|
|
|
0
|
|
4754
|
0
|
0
|
|
|
|
0
|
my $unlink = 0; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
4755
|
0
|
|
|
|
|
0
|
for (@_) { |
4756
|
|
|
|
|
|
|
if (CORE::unlink) { |
4757
|
|
|
|
|
|
|
$unlink++; |
4758
|
|
|
|
|
|
|
} |
4759
|
|
|
|
|
|
|
elsif (Ehp15::d($_)) { |
4760
|
0
|
|
|
|
|
0
|
} |
4761
|
0
|
0
|
|
|
|
0
|
elsif (_MSWin32_5Cended_path($_)) { |
|
0
|
|
|
|
|
0
|
|
4762
|
0
|
0
|
|
|
|
0
|
my @char = /\G (?>$q_char) /oxmsg; |
4763
|
0
|
|
|
|
|
0
|
my $file = join '', map {{'/' => '\\'}->{$_} || $_} @char; |
4764
|
|
|
|
|
|
|
if ($file =~ / \A (?:$q_char)*? [ ] /oxms) { |
4765
|
0
|
|
|
|
|
0
|
$file = qq{"$file"}; |
4766
|
0
|
0
|
|
|
|
0
|
} |
4767
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
4768
|
|
|
|
|
|
|
if (_open_r($fh, $_)) { |
4769
|
|
|
|
|
|
|
close($fh) or die "Can't close file: $_: $!"; |
4770
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
4771
|
0
|
|
|
|
|
0
|
# cmd.exe on Windows NT, Windows 2000, Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 or later |
4772
|
|
|
|
|
|
|
if ((defined $ENV{'OS'}) and ($ENV{'OS'} eq 'Windows_NT')) { |
4773
|
|
|
|
|
|
|
CORE::system 'DEL', '/F', $file, '2>NUL'; |
4774
|
|
|
|
|
|
|
} |
4775
|
|
|
|
|
|
|
|
4776
|
0
|
|
|
|
|
0
|
# Win95Cmd.exe on any Windows (when SET PERL5SHELL=Win95Cmd.exe /c, `var` returns "Windows 2000") |
4777
|
|
|
|
|
|
|
elsif (qx{ver} =~ /\b(?:Windows 2000)\b/oms) { |
4778
|
|
|
|
|
|
|
CORE::system 'DEL', '/F', $file, '2>NUL'; |
4779
|
|
|
|
|
|
|
} |
4780
|
|
|
|
|
|
|
|
4781
|
|
|
|
|
|
|
# COMMAND.COM on Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition |
4782
|
0
|
|
|
|
|
0
|
# command.com can not "2>NUL" |
4783
|
0
|
|
|
|
|
0
|
else { |
4784
|
|
|
|
|
|
|
CORE::system 'ATTRIB', '-R', $file; # clears Read-only file attribute |
4785
|
|
|
|
|
|
|
CORE::system 'DEL', $file; |
4786
|
0
|
0
|
|
|
|
0
|
} |
4787
|
0
|
0
|
|
|
|
0
|
|
4788
|
|
|
|
|
|
|
if (_open_r($fh, $_)) { |
4789
|
|
|
|
|
|
|
close($fh) or die "Can't close file: $_: $!"; |
4790
|
0
|
|
|
|
|
0
|
} |
4791
|
|
|
|
|
|
|
else { |
4792
|
|
|
|
|
|
|
$unlink++; |
4793
|
|
|
|
|
|
|
} |
4794
|
|
|
|
|
|
|
} |
4795
|
0
|
|
|
|
|
0
|
} |
4796
|
|
|
|
|
|
|
} |
4797
|
|
|
|
|
|
|
return $unlink; |
4798
|
|
|
|
|
|
|
} |
4799
|
|
|
|
|
|
|
|
4800
|
|
|
|
|
|
|
# |
4801
|
|
|
|
|
|
|
# HP-15 chdir |
4802
|
|
|
|
|
|
|
# |
4803
|
0
|
0
|
|
0
|
0
|
0
|
sub Ehp15::chdir(;$) { |
4804
|
0
|
|
|
|
|
0
|
|
4805
|
|
|
|
|
|
|
if (@_ == 0) { |
4806
|
|
|
|
|
|
|
return CORE::chdir; |
4807
|
0
|
|
|
|
|
0
|
} |
4808
|
|
|
|
|
|
|
|
4809
|
0
|
0
|
|
|
|
0
|
my($dir) = @_; |
4810
|
0
|
0
|
|
|
|
0
|
|
4811
|
0
|
|
|
|
|
0
|
if (_MSWin32_5Cended_path($dir)) { |
4812
|
|
|
|
|
|
|
if (not Ehp15::d $dir) { |
4813
|
|
|
|
|
|
|
return 0; |
4814
|
0
|
0
|
0
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
4815
|
0
|
|
|
|
|
0
|
|
4816
|
|
|
|
|
|
|
if ($] =~ /^5\.005/oxms) { |
4817
|
|
|
|
|
|
|
return CORE::chdir $dir; |
4818
|
0
|
|
|
|
|
0
|
} |
4819
|
0
|
|
|
|
|
0
|
elsif (($] =~ /^(?:5\.006|5\.008000)/oxms) and ($^O eq 'MSWin32')) { |
4820
|
|
|
|
|
|
|
local $@; |
4821
|
|
|
|
|
|
|
my $chdir = CORE::eval q{ |
4822
|
|
|
|
|
|
|
CORE::require 'jacode.pl'; |
4823
|
|
|
|
|
|
|
|
4824
|
|
|
|
|
|
|
# P.676 ${^WIDE_SYSTEM_CALLS} |
4825
|
|
|
|
|
|
|
# in Chapter 28: Special Names |
4826
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
4827
|
|
|
|
|
|
|
|
4828
|
|
|
|
|
|
|
# P.790 ${^WIDE_SYSTEM_CALLS} |
4829
|
|
|
|
|
|
|
# in Chapter 25: Special Names |
4830
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
4831
|
|
|
|
|
|
|
|
4832
|
|
|
|
|
|
|
local ${^WIDE_SYSTEM_CALLS} = 1; |
4833
|
0
|
0
|
|
|
|
0
|
return CORE::chdir jcode::utf8($dir,'sjis'); |
4834
|
0
|
|
|
|
|
0
|
}; |
4835
|
|
|
|
|
|
|
if (not $@) { |
4836
|
|
|
|
|
|
|
return $chdir; |
4837
|
|
|
|
|
|
|
} |
4838
|
|
|
|
|
|
|
} |
4839
|
|
|
|
|
|
|
|
4840
|
|
|
|
|
|
|
# old idea (Win32 module required) |
4841
|
|
|
|
|
|
|
elsif (0) { |
4842
|
|
|
|
|
|
|
local $@; |
4843
|
|
|
|
|
|
|
my $shortdir = ''; |
4844
|
|
|
|
|
|
|
my $chdir = CORE::eval q{ |
4845
|
|
|
|
|
|
|
use Win32; |
4846
|
|
|
|
|
|
|
$shortdir = Win32::GetShortPathName($dir); |
4847
|
|
|
|
|
|
|
if ($shortdir ne $dir) { |
4848
|
|
|
|
|
|
|
return CORE::chdir $shortdir; |
4849
|
|
|
|
|
|
|
} |
4850
|
|
|
|
|
|
|
else { |
4851
|
|
|
|
|
|
|
return 0; |
4852
|
|
|
|
|
|
|
} |
4853
|
|
|
|
|
|
|
}; |
4854
|
|
|
|
|
|
|
if ($@) { |
4855
|
|
|
|
|
|
|
my @char = $dir =~ /\G (?>$q_char) /oxmsg; |
4856
|
|
|
|
|
|
|
while ($char[-1] eq "\x5C") { |
4857
|
|
|
|
|
|
|
pop @char; |
4858
|
|
|
|
|
|
|
} |
4859
|
|
|
|
|
|
|
$dir = join '', @char; |
4860
|
|
|
|
|
|
|
croak "Perl$] can't chdir to $dir (chr(0x5C) ended path), Win32.pm module may help you"; |
4861
|
|
|
|
|
|
|
} |
4862
|
|
|
|
|
|
|
elsif ($shortdir eq $dir) { |
4863
|
|
|
|
|
|
|
my @char = $dir =~ /\G (?>$q_char) /oxmsg; |
4864
|
|
|
|
|
|
|
while ($char[-1] eq "\x5C") { |
4865
|
|
|
|
|
|
|
pop @char; |
4866
|
|
|
|
|
|
|
} |
4867
|
|
|
|
|
|
|
$dir = join '', @char; |
4868
|
|
|
|
|
|
|
croak "Perl$] can't chdir to $dir (chr(0x5C) ended path)"; |
4869
|
|
|
|
|
|
|
} |
4870
|
|
|
|
|
|
|
return $chdir; |
4871
|
|
|
|
|
|
|
} |
4872
|
0
|
|
|
|
|
0
|
|
4873
|
|
|
|
|
|
|
# rejected idea ... |
4874
|
|
|
|
|
|
|
elsif (0) { |
4875
|
|
|
|
|
|
|
|
4876
|
|
|
|
|
|
|
# MSDN SetCurrentDirectory function |
4877
|
|
|
|
|
|
|
# http://msdn.microsoft.com/ja-jp/library/windows/desktop/aa365530(v=vs.85).aspx |
4878
|
|
|
|
|
|
|
# |
4879
|
|
|
|
|
|
|
# Data Execution Prevention (DEP) |
4880
|
|
|
|
|
|
|
# http://vlaurie.com/computers2/Articles/dep.htm |
4881
|
|
|
|
|
|
|
# |
4882
|
|
|
|
|
|
|
# Learning x86 assembler with Perl -- Shibuya.pm#11 |
4883
|
|
|
|
|
|
|
# http://developer.cybozu.co.jp/takesako/2009/06/perl-x86-shibuy.html |
4884
|
|
|
|
|
|
|
# |
4885
|
|
|
|
|
|
|
# Introduction to Win32::API programming in Perl |
4886
|
|
|
|
|
|
|
# http://d.hatena.ne.jp/TAKESAKO/20090324/1237879559 |
4887
|
|
|
|
|
|
|
# |
4888
|
|
|
|
|
|
|
# DynaLoader - Dynamically load C libraries into Perl code |
4889
|
|
|
|
|
|
|
# http://perldoc.perl.org/DynaLoader.html |
4890
|
|
|
|
|
|
|
# |
4891
|
|
|
|
|
|
|
# Basic knowledge of DynaLoader |
4892
|
|
|
|
|
|
|
# http://blog.64p.org/entry/20090313/1236934042 |
4893
|
|
|
|
|
|
|
|
4894
|
|
|
|
|
|
|
if (($] =~ /^5\.006/oxms) and |
4895
|
|
|
|
|
|
|
($^O eq 'MSWin32') and |
4896
|
|
|
|
|
|
|
($ENV{'PROCESSOR_ARCHITECTURE'} eq 'x86') and |
4897
|
|
|
|
|
|
|
CORE::eval(q{CORE::require 'Dyna'.'Loader'}) |
4898
|
|
|
|
|
|
|
) { |
4899
|
|
|
|
|
|
|
my $x86 = join('', |
4900
|
|
|
|
|
|
|
|
4901
|
|
|
|
|
|
|
# PUSH Iv |
4902
|
|
|
|
|
|
|
"\x68", pack('P', "$dir\\\0"), |
4903
|
|
|
|
|
|
|
|
4904
|
|
|
|
|
|
|
# MOV eAX, Iv |
4905
|
|
|
|
|
|
|
"\xb8", pack('L', |
4906
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_find_symbol'}{'CODE'}->( |
4907
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_load_file'}{'CODE'}->("$ENV{'SystemRoot'}\\system32\\kernel32.dll"), |
4908
|
|
|
|
|
|
|
'SetCurrentDirectoryA' |
4909
|
|
|
|
|
|
|
) |
4910
|
|
|
|
|
|
|
), |
4911
|
|
|
|
|
|
|
|
4912
|
|
|
|
|
|
|
# CALL eAX |
4913
|
|
|
|
|
|
|
"\xff\xd0", |
4914
|
|
|
|
|
|
|
|
4915
|
|
|
|
|
|
|
# RETN |
4916
|
|
|
|
|
|
|
"\xc3", |
4917
|
|
|
|
|
|
|
); |
4918
|
|
|
|
|
|
|
*{'Dyna'.'Loader::dl_install_xsub'}{'CODE'}->('_SetCurrentDirectoryA', unpack('L', pack 'P', $x86)); |
4919
|
|
|
|
|
|
|
_SetCurrentDirectoryA(); |
4920
|
|
|
|
|
|
|
chomp(my $chdir = qx{chdir}); |
4921
|
|
|
|
|
|
|
if (Ehp15::fc($chdir) eq Ehp15::fc($dir)) { |
4922
|
|
|
|
|
|
|
return 1; |
4923
|
|
|
|
|
|
|
} |
4924
|
|
|
|
|
|
|
else { |
4925
|
|
|
|
|
|
|
return 0; |
4926
|
|
|
|
|
|
|
} |
4927
|
|
|
|
|
|
|
} |
4928
|
|
|
|
|
|
|
} |
4929
|
|
|
|
|
|
|
|
4930
|
|
|
|
|
|
|
# COMMAND.COM's unhelpful tips: |
4931
|
|
|
|
|
|
|
# Displays a list of files and subdirectories in a directory. |
4932
|
|
|
|
|
|
|
# http://www.lagmonster.org/docs/DOS7/z-dir.html |
4933
|
|
|
|
|
|
|
# |
4934
|
|
|
|
|
|
|
# Syntax: |
4935
|
|
|
|
|
|
|
# |
4936
|
|
|
|
|
|
|
# DIR [drive:] [path] [filename] [/Switches] |
4937
|
|
|
|
|
|
|
# |
4938
|
|
|
|
|
|
|
# /Z Long file names are not displayed in the file listing |
4939
|
|
|
|
|
|
|
# |
4940
|
|
|
|
|
|
|
# Limitations |
4941
|
|
|
|
|
|
|
# The undocumented /Z switch (no long names) would appear to |
4942
|
|
|
|
|
|
|
# have been not fully developed and has a couple of problems: |
4943
|
|
|
|
|
|
|
# |
4944
|
|
|
|
|
|
|
# 1. It will only work if: |
4945
|
|
|
|
|
|
|
# There is no path specified (ie. for the current directory in |
4946
|
|
|
|
|
|
|
# the current drive) |
4947
|
|
|
|
|
|
|
# The path is specified as the root directory of any drive |
4948
|
|
|
|
|
|
|
# (eg. C:\, D:\, etc.) |
4949
|
|
|
|
|
|
|
# The path is specified as the current directory of any drive |
4950
|
|
|
|
|
|
|
# by using the drive letter only (eg. C:, D:, etc.) |
4951
|
|
|
|
|
|
|
# The path is specified as the parent directory using the .. |
4952
|
|
|
|
|
|
|
# notation (eg. DIR .. /Z) |
4953
|
|
|
|
|
|
|
# Any other syntax results in a "File Not Found" error message. |
4954
|
|
|
|
|
|
|
# |
4955
|
|
|
|
|
|
|
# 2. The /Z switch is compatable with the /S switch to show |
4956
|
|
|
|
|
|
|
# subdirectories (as long as the above rules are followed) and |
4957
|
|
|
|
|
|
|
# all the files are shown with short names only. The |
4958
|
|
|
|
|
|
|
# subdirectories are also shown with short names only. However, |
4959
|
|
|
|
|
|
|
# the header for each subdirectory after the first level gives |
4960
|
|
|
|
|
|
|
# the subdirectory's long name. |
4961
|
|
|
|
|
|
|
# |
4962
|
|
|
|
|
|
|
# 3. The /Z switch is also compatable with the /B switch to give |
4963
|
|
|
|
|
|
|
# a simple list of files with short names only. When used with |
4964
|
|
|
|
|
|
|
# the /S switch as well, all files are listed with their full |
4965
|
|
|
|
|
|
|
# paths. The file names themselves are all in short form, and |
4966
|
|
|
|
|
|
|
# the path of those files in the current directory are in short |
4967
|
|
|
|
|
|
|
# form, but the paths of any files in subdirectories are in |
4968
|
0
|
|
|
|
|
0
|
# long filename form. |
4969
|
0
|
|
|
|
|
0
|
|
4970
|
0
|
|
|
|
|
0
|
my $shortdir = ''; |
4971
|
0
|
|
|
|
|
0
|
my $i = 0; |
4972
|
0
|
|
|
|
|
0
|
my @subdir = (); |
4973
|
0
|
0
|
0
|
|
|
0
|
while ($dir =~ / \G ($q_char) /oxgc) { |
4974
|
0
|
|
|
|
|
0
|
my $char = $1; |
4975
|
0
|
|
|
|
|
0
|
if (($char eq '\\') or ($char eq '/')) { |
4976
|
0
|
|
|
|
|
0
|
$i++; |
4977
|
|
|
|
|
|
|
$subdir[$i] = $char; |
4978
|
|
|
|
|
|
|
$i++; |
4979
|
0
|
|
|
|
|
0
|
} |
4980
|
|
|
|
|
|
|
else { |
4981
|
|
|
|
|
|
|
$subdir[$i] .= $char; |
4982
|
0
|
0
|
0
|
|
|
0
|
} |
4983
|
0
|
|
|
|
|
0
|
} |
4984
|
|
|
|
|
|
|
if (($subdir[-1] eq '\\') or ($subdir[-1] eq '/')) { |
4985
|
|
|
|
|
|
|
pop @subdir; |
4986
|
|
|
|
|
|
|
} |
4987
|
|
|
|
|
|
|
|
4988
|
|
|
|
|
|
|
# P.504 PERL5SHELL (Microsoft ports only) |
4989
|
|
|
|
|
|
|
# in Chapter 19: The Command-Line Interface |
4990
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
4991
|
|
|
|
|
|
|
|
4992
|
|
|
|
|
|
|
# P.597 PERL5SHELL (Microsoft ports only) |
4993
|
|
|
|
|
|
|
# in Chapter 17: The Command-Line Interface |
4994
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
4995
|
|
|
|
|
|
|
|
4996
|
0
|
0
|
0
|
|
|
0
|
# Win95Cmd.exe on any Windows (when SET PERL5SHELL=Win95Cmd.exe /c, `var` returns "Windows 2000") |
|
|
0
|
|
|
|
|
|
4997
|
0
|
|
|
|
|
0
|
# cmd.exe on Windows NT, Windows 2000 |
4998
|
0
|
|
|
|
|
0
|
if (qx{ver} =~ /\b(?:Windows NT|Windows 2000)\b/oms) { |
|
0
|
|
|
|
|
0
|
|
4999
|
0
|
0
|
|
|
|
0
|
chomp(my @dirx = grep //oxms, qx{dir /ad /x "$dir*" 2>NUL}); |
5000
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5001
|
|
|
|
|
|
|
if (Ehp15::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Ehp15::fc($subdir[-1])) { |
5002
|
0
|
|
|
|
|
0
|
|
5003
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----vv |
5004
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 39, 8+1+3; |
5005
|
0
|
|
|
|
|
0
|
$shortleafdir =~ s/ [ ]+ \z//oxms; |
5006
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5007
|
|
|
|
|
|
|
last; |
5008
|
|
|
|
|
|
|
} |
5009
|
|
|
|
|
|
|
} |
5010
|
|
|
|
|
|
|
} |
5011
|
|
|
|
|
|
|
|
5012
|
|
|
|
|
|
|
# an idea (not so portable, only Windows 2000 or later) |
5013
|
|
|
|
|
|
|
elsif (0) { |
5014
|
|
|
|
|
|
|
chomp($shortdir = qx{for %I in ("$dir") do \@echo %~sI 2>NUL}); |
5015
|
|
|
|
|
|
|
} |
5016
|
|
|
|
|
|
|
|
5017
|
0
|
|
|
|
|
0
|
# cmd.exe on Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 or later |
5018
|
0
|
|
|
|
|
0
|
elsif ((defined $ENV{'OS'}) and ($ENV{'OS'} eq 'Windows_NT')) { |
|
0
|
|
|
|
|
0
|
|
5019
|
0
|
0
|
|
|
|
0
|
chomp(my @dirx = grep //oxms, qx{dir /ad /x "$dir*" 2>NUL}); |
5020
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5021
|
|
|
|
|
|
|
if (Ehp15::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Ehp15::fc($subdir[-1])) { |
5022
|
0
|
|
|
|
|
0
|
|
5023
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----vv |
5024
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 36, 8+1+3; |
5025
|
0
|
|
|
|
|
0
|
$shortleafdir =~ s/ [ ]+ \z//oxms; |
5026
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5027
|
|
|
|
|
|
|
last; |
5028
|
|
|
|
|
|
|
} |
5029
|
|
|
|
|
|
|
} |
5030
|
|
|
|
|
|
|
} |
5031
|
|
|
|
|
|
|
|
5032
|
0
|
|
|
|
|
0
|
# COMMAND.COM on Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition |
5033
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
5034
|
0
|
0
|
|
|
|
0
|
chomp(my @dirx = grep //oxms, qx{dir /ad "$dir*"}); |
5035
|
|
|
|
|
|
|
for my $dirx (sort { CORE::length($a) <=> CORE::length($b) } @dirx) { |
5036
|
|
|
|
|
|
|
if (Ehp15::fc(CORE::substr $dirx,-CORE::length($subdir[-1]),CORE::length($subdir[-1])) eq Ehp15::fc($subdir[-1])) { |
5037
|
0
|
|
|
|
|
0
|
|
5038
|
0
|
|
|
|
|
0
|
# short file name (8dot3name) here-----v |
5039
|
0
|
|
|
|
|
0
|
my $shortleafdir = CORE::substr $dirx, 0, 8+1+3; |
5040
|
0
|
|
|
|
|
0
|
CORE::substr($shortleafdir,8,1) = '.'; |
5041
|
0
|
|
|
|
|
0
|
$shortleafdir =~ s/ \. [ ]+ \z//oxms; |
5042
|
|
|
|
|
|
|
$shortdir = join '', @subdir[0..$#subdir-1], $shortleafdir; |
5043
|
|
|
|
|
|
|
last; |
5044
|
|
|
|
|
|
|
} |
5045
|
|
|
|
|
|
|
} |
5046
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
5047
|
0
|
|
|
|
|
0
|
|
5048
|
|
|
|
|
|
|
if ($shortdir eq '') { |
5049
|
|
|
|
|
|
|
return 0; |
5050
|
0
|
|
|
|
|
0
|
} |
5051
|
|
|
|
|
|
|
elsif (Ehp15::fc($shortdir) eq Ehp15::fc($dir)) { |
5052
|
0
|
|
|
|
|
0
|
return 0; |
5053
|
|
|
|
|
|
|
} |
5054
|
|
|
|
|
|
|
return CORE::chdir $shortdir; |
5055
|
0
|
|
|
|
|
0
|
} |
5056
|
|
|
|
|
|
|
else { |
5057
|
|
|
|
|
|
|
return CORE::chdir $dir; |
5058
|
|
|
|
|
|
|
} |
5059
|
|
|
|
|
|
|
} |
5060
|
|
|
|
|
|
|
|
5061
|
|
|
|
|
|
|
# |
5062
|
|
|
|
|
|
|
# HP-15 chr(0x5C) ended path on MSWin32 |
5063
|
|
|
|
|
|
|
# |
5064
|
0
|
50
|
33
|
768
|
|
0
|
sub _MSWin32_5Cended_path { |
5065
|
768
|
50
|
|
|
|
4973
|
|
5066
|
768
|
|
|
|
|
4331
|
if ((@_ >= 1) and ($_[0] ne '')) { |
5067
|
0
|
0
|
|
|
|
0
|
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) { |
5068
|
0
|
|
|
|
|
0
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
5069
|
|
|
|
|
|
|
if ($char[-1] =~ / \x5C \z/oxms) { |
5070
|
|
|
|
|
|
|
return 1; |
5071
|
|
|
|
|
|
|
} |
5072
|
0
|
|
|
|
|
0
|
} |
5073
|
|
|
|
|
|
|
} |
5074
|
|
|
|
|
|
|
return undef; |
5075
|
|
|
|
|
|
|
} |
5076
|
|
|
|
|
|
|
|
5077
|
|
|
|
|
|
|
# |
5078
|
|
|
|
|
|
|
# do HP-15 file |
5079
|
|
|
|
|
|
|
# |
5080
|
768
|
|
|
0
|
0
|
2050
|
sub Ehp15::do($) { |
5081
|
|
|
|
|
|
|
|
5082
|
0
|
|
|
|
|
0
|
my($filename) = @_; |
5083
|
|
|
|
|
|
|
|
5084
|
|
|
|
|
|
|
my $realfilename; |
5085
|
|
|
|
|
|
|
my $result; |
5086
|
0
|
|
|
|
|
0
|
ITER_DO: |
|
0
|
|
|
|
|
0
|
|
5087
|
0
|
0
|
|
|
|
0
|
{ |
5088
|
0
|
|
|
|
|
0
|
for my $prefix (@INC) { |
5089
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5090
|
|
|
|
|
|
|
$realfilename = "$prefix$filename"; |
5091
|
0
|
|
|
|
|
0
|
} |
5092
|
|
|
|
|
|
|
else { |
5093
|
|
|
|
|
|
|
$realfilename = "$prefix/$filename"; |
5094
|
0
|
0
|
|
|
|
0
|
} |
5095
|
|
|
|
|
|
|
|
5096
|
0
|
|
|
|
|
0
|
if (Ehp15::f($realfilename)) { |
5097
|
|
|
|
|
|
|
|
5098
|
0
|
0
|
|
|
|
0
|
my $script = ''; |
5099
|
0
|
|
|
|
|
0
|
|
5100
|
0
|
|
|
|
|
0
|
if (Ehp15::e("$realfilename.e")) { |
5101
|
0
|
|
|
|
|
0
|
my $e_mtime = (Ehp15::stat("$realfilename.e"))[9]; |
5102
|
0
|
0
|
0
|
|
|
0
|
my $mtime = (Ehp15::stat($realfilename))[9]; |
5103
|
0
|
|
|
|
|
0
|
my $module_mtime = (Ehp15::stat(__FILE__))[9]; |
5104
|
|
|
|
|
|
|
if (($e_mtime < $mtime) or ($mtime < $module_mtime)) { |
5105
|
|
|
|
|
|
|
Ehp15::unlink "$realfilename.e"; |
5106
|
|
|
|
|
|
|
} |
5107
|
0
|
0
|
|
|
|
0
|
} |
5108
|
0
|
|
|
|
|
0
|
|
5109
|
0
|
0
|
|
|
|
0
|
if (Ehp15::e("$realfilename.e")) { |
5110
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5111
|
0
|
|
|
|
|
0
|
if (_open_r($fh, "$realfilename.e")) { |
5112
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5113
|
|
|
|
|
|
|
CORE::eval q{ |
5114
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5115
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5116
|
|
|
|
|
|
|
}; |
5117
|
|
|
|
|
|
|
} |
5118
|
|
|
|
|
|
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5119
|
|
|
|
|
|
|
|
5120
|
|
|
|
|
|
|
# P.419 File Locking |
5121
|
|
|
|
|
|
|
# in Chapter 16: Interprocess Communication |
5122
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5123
|
|
|
|
|
|
|
|
5124
|
|
|
|
|
|
|
# P.524 File Locking |
5125
|
|
|
|
|
|
|
# in Chapter 15: Interprocess Communication |
5126
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5127
|
|
|
|
|
|
|
|
5128
|
0
|
|
|
|
|
0
|
# (and so on) |
5129
|
0
|
0
|
|
|
|
0
|
|
5130
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5131
|
|
|
|
|
|
|
if ($@) { |
5132
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename.e"; |
5133
|
|
|
|
|
|
|
} |
5134
|
0
|
|
|
|
|
0
|
} |
5135
|
|
|
|
|
|
|
else { |
5136
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5137
|
0
|
|
|
|
|
0
|
} |
5138
|
0
|
0
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5139
|
0
|
|
|
|
|
0
|
$script = <$fh>; |
5140
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5141
|
|
|
|
|
|
|
CORE::eval q{ |
5142
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5143
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5144
|
0
|
0
|
|
|
|
0
|
}; |
5145
|
|
|
|
|
|
|
} |
5146
|
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename.e: $!"; |
5147
|
|
|
|
|
|
|
} |
5148
|
0
|
|
|
|
|
0
|
} |
5149
|
0
|
0
|
|
|
|
0
|
else { |
5150
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5151
|
0
|
|
|
|
|
0
|
if (_open_r($fh, $realfilename)) { |
5152
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5153
|
|
|
|
|
|
|
CORE::eval q{ |
5154
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5155
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock($realfilename); |
5156
|
|
|
|
|
|
|
}; |
5157
|
0
|
|
|
|
|
0
|
} |
5158
|
0
|
0
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5159
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5160
|
|
|
|
|
|
|
if ($@) { |
5161
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename"; |
5162
|
|
|
|
|
|
|
} |
5163
|
0
|
|
|
|
|
0
|
} |
5164
|
|
|
|
|
|
|
else { |
5165
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5166
|
0
|
|
|
|
|
0
|
} |
5167
|
0
|
0
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5168
|
0
|
|
|
|
|
0
|
$script = <$fh>; |
5169
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5170
|
|
|
|
|
|
|
CORE::eval q{ |
5171
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5172
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock($realfilename); |
5173
|
0
|
0
|
|
|
|
0
|
}; |
5174
|
|
|
|
|
|
|
} |
5175
|
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename.e: $!"; |
5176
|
0
|
0
|
|
|
|
0
|
} |
5177
|
0
|
|
|
|
|
0
|
|
5178
|
0
|
|
|
|
|
0
|
if ($script =~ /^ (?>\s*) use (?>\s+) HP15 (?>\s*) ([^\x80-\xA0\xE0-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
5179
|
0
|
|
|
|
|
0
|
CORE::require HP15; |
5180
|
0
|
0
|
|
|
|
0
|
$script = HP15::escape_script($script); |
5181
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5182
|
0
|
|
|
|
|
0
|
open($fh, ">$realfilename.e") or die __FILE__, ": Can't write open file: $realfilename.e\n"; |
5183
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5184
|
|
|
|
|
|
|
CORE::eval q{ |
5185
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5186
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5187
|
|
|
|
|
|
|
}; |
5188
|
0
|
|
|
|
|
0
|
} |
5189
|
0
|
0
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5190
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX | LOCK_NB) }; |
5191
|
|
|
|
|
|
|
if ($@) { |
5192
|
|
|
|
|
|
|
carp "Can't immediately write-lock the file: $realfilename.e"; |
5193
|
|
|
|
|
|
|
} |
5194
|
0
|
|
|
|
|
0
|
} |
5195
|
|
|
|
|
|
|
else { |
5196
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX) }; |
5197
|
0
|
0
|
|
|
|
0
|
} |
5198
|
0
|
|
|
|
|
0
|
CORE::eval q{ truncate($fh, 0) }; |
|
0
|
|
|
|
|
0
|
|
5199
|
0
|
0
|
|
|
|
0
|
seek($fh, 0, 0) or croak "Can't seek file: $realfilename.e"; |
5200
|
0
|
|
|
|
|
0
|
print {$fh} $script; |
5201
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5202
|
|
|
|
|
|
|
CORE::eval q{ |
5203
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5204
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5205
|
0
|
0
|
|
|
|
0
|
}; |
5206
|
|
|
|
|
|
|
} |
5207
|
|
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename.e: $!"; |
5208
|
|
|
|
|
|
|
} |
5209
|
|
|
|
|
|
|
} |
5210
|
389
|
|
|
389
|
|
14265
|
|
|
389
|
|
|
|
|
1101
|
|
|
389
|
|
|
|
|
374372
|
|
|
0
|
|
|
|
|
0
|
|
5211
|
0
|
|
|
|
|
0
|
{ |
5212
|
|
|
|
|
|
|
no strict; |
5213
|
0
|
|
|
|
|
0
|
$result = scalar CORE::eval $script; |
5214
|
|
|
|
|
|
|
} |
5215
|
|
|
|
|
|
|
last ITER_DO; |
5216
|
|
|
|
|
|
|
} |
5217
|
|
|
|
|
|
|
} |
5218
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
5219
|
0
|
|
|
|
|
0
|
|
5220
|
0
|
|
|
|
|
0
|
if ($@) { |
5221
|
|
|
|
|
|
|
$INC{$filename} = undef; |
5222
|
|
|
|
|
|
|
return undef; |
5223
|
0
|
|
|
|
|
0
|
} |
5224
|
|
|
|
|
|
|
elsif (not $result) { |
5225
|
|
|
|
|
|
|
return undef; |
5226
|
0
|
|
|
|
|
0
|
} |
5227
|
0
|
|
|
|
|
0
|
else { |
5228
|
|
|
|
|
|
|
$INC{$filename} = $realfilename; |
5229
|
|
|
|
|
|
|
return $result; |
5230
|
|
|
|
|
|
|
} |
5231
|
|
|
|
|
|
|
} |
5232
|
|
|
|
|
|
|
|
5233
|
|
|
|
|
|
|
# |
5234
|
|
|
|
|
|
|
# require HP-15 file |
5235
|
|
|
|
|
|
|
# |
5236
|
|
|
|
|
|
|
|
5237
|
|
|
|
|
|
|
# require |
5238
|
|
|
|
|
|
|
# in Chapter 3: Functions |
5239
|
|
|
|
|
|
|
# of ISBN 1-56592-149-6 Programming Perl, Second Edition. |
5240
|
|
|
|
|
|
|
# |
5241
|
|
|
|
|
|
|
# sub require { |
5242
|
|
|
|
|
|
|
# my($filename) = @_; |
5243
|
|
|
|
|
|
|
# return 1 if $INC{$filename}; |
5244
|
|
|
|
|
|
|
# my($realfilename, $result); |
5245
|
|
|
|
|
|
|
# ITER: { |
5246
|
|
|
|
|
|
|
# foreach $prefix (@INC) { |
5247
|
|
|
|
|
|
|
# $realfilename = "$prefix/$filename"; |
5248
|
|
|
|
|
|
|
# if (-f $realfilename) { |
5249
|
|
|
|
|
|
|
# $result = CORE::eval `cat $realfilename`; |
5250
|
|
|
|
|
|
|
# last ITER; |
5251
|
|
|
|
|
|
|
# } |
5252
|
|
|
|
|
|
|
# } |
5253
|
|
|
|
|
|
|
# die "Can't find $filename in \@INC"; |
5254
|
|
|
|
|
|
|
# } |
5255
|
|
|
|
|
|
|
# die $@ if $@; |
5256
|
|
|
|
|
|
|
# die "$filename did not return true value" unless $result; |
5257
|
|
|
|
|
|
|
# $INC{$filename} = $realfilename; |
5258
|
|
|
|
|
|
|
# return $result; |
5259
|
|
|
|
|
|
|
# } |
5260
|
|
|
|
|
|
|
|
5261
|
|
|
|
|
|
|
# require |
5262
|
|
|
|
|
|
|
# in Chapter 9: perlfunc: Perl builtin functions |
5263
|
|
|
|
|
|
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
5264
|
|
|
|
|
|
|
# |
5265
|
|
|
|
|
|
|
# sub require { |
5266
|
|
|
|
|
|
|
# my($filename) = @_; |
5267
|
|
|
|
|
|
|
# if (exists $INC{$filename}) { |
5268
|
|
|
|
|
|
|
# return 1 if $INC{$filename}; |
5269
|
|
|
|
|
|
|
# die "Compilation failed in require"; |
5270
|
|
|
|
|
|
|
# } |
5271
|
|
|
|
|
|
|
# my($realfilename, $result); |
5272
|
|
|
|
|
|
|
# ITER: { |
5273
|
|
|
|
|
|
|
# foreach $prefix (@INC) { |
5274
|
|
|
|
|
|
|
# $realfilename = "$prefix/$filename"; |
5275
|
|
|
|
|
|
|
# if (-f $realfilename) { |
5276
|
|
|
|
|
|
|
# $INC{$filename} = $realfilename; |
5277
|
|
|
|
|
|
|
# $result = do $realfilename; |
5278
|
|
|
|
|
|
|
# last ITER; |
5279
|
|
|
|
|
|
|
# } |
5280
|
|
|
|
|
|
|
# } |
5281
|
|
|
|
|
|
|
# die "Can't find $filename in \@INC"; |
5282
|
|
|
|
|
|
|
# } |
5283
|
|
|
|
|
|
|
# if ($@) { |
5284
|
|
|
|
|
|
|
# $INC{$filename} = undef; |
5285
|
|
|
|
|
|
|
# die $@; |
5286
|
|
|
|
|
|
|
# } |
5287
|
|
|
|
|
|
|
# elsif (!$result) { |
5288
|
|
|
|
|
|
|
# delete $INC{$filename}; |
5289
|
|
|
|
|
|
|
# die "$filename did not return true value"; |
5290
|
|
|
|
|
|
|
# } |
5291
|
|
|
|
|
|
|
# else { |
5292
|
|
|
|
|
|
|
# return $result; |
5293
|
|
|
|
|
|
|
# } |
5294
|
|
|
|
|
|
|
# } |
5295
|
|
|
|
|
|
|
|
5296
|
0
|
0
|
|
0
|
0
|
0
|
sub Ehp15::require(;$) { |
5297
|
|
|
|
|
|
|
|
5298
|
0
|
0
|
|
|
|
0
|
local $_ = shift if @_; |
5299
|
0
|
0
|
|
|
|
0
|
|
5300
|
0
|
|
|
|
|
0
|
if (exists $INC{$_}) { |
5301
|
|
|
|
|
|
|
return 1 if $INC{$_}; |
5302
|
|
|
|
|
|
|
croak "Compilation failed in require: $_"; |
5303
|
|
|
|
|
|
|
} |
5304
|
|
|
|
|
|
|
|
5305
|
|
|
|
|
|
|
# jcode.pl |
5306
|
|
|
|
|
|
|
# ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/ |
5307
|
|
|
|
|
|
|
|
5308
|
|
|
|
|
|
|
# jacode.pl |
5309
|
0
|
0
|
|
|
|
0
|
# http://search.cpan.org/dist/jacode/ |
5310
|
0
|
|
|
|
|
0
|
|
5311
|
|
|
|
|
|
|
if (/ \b (?: jcode\.pl | jacode(?>[0-9]*)\.pl ) \z /oxms) { |
5312
|
|
|
|
|
|
|
return CORE::require($_); |
5313
|
0
|
|
|
|
|
0
|
} |
5314
|
|
|
|
|
|
|
|
5315
|
|
|
|
|
|
|
my $realfilename; |
5316
|
|
|
|
|
|
|
my $result; |
5317
|
0
|
|
|
|
|
0
|
ITER_REQUIRE: |
|
0
|
|
|
|
|
0
|
|
5318
|
0
|
0
|
|
|
|
0
|
{ |
5319
|
0
|
|
|
|
|
0
|
for my $prefix (@INC) { |
5320
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5321
|
|
|
|
|
|
|
$realfilename = "$prefix$_"; |
5322
|
0
|
|
|
|
|
0
|
} |
5323
|
|
|
|
|
|
|
else { |
5324
|
|
|
|
|
|
|
$realfilename = "$prefix/$_"; |
5325
|
0
|
0
|
|
|
|
0
|
} |
5326
|
0
|
|
|
|
|
0
|
|
5327
|
|
|
|
|
|
|
if (Ehp15::f($realfilename)) { |
5328
|
0
|
|
|
|
|
0
|
$INC{$_} = $realfilename; |
5329
|
|
|
|
|
|
|
|
5330
|
0
|
0
|
|
|
|
0
|
my $script = ''; |
5331
|
0
|
|
|
|
|
0
|
|
5332
|
0
|
|
|
|
|
0
|
if (Ehp15::e("$realfilename.e")) { |
5333
|
0
|
|
|
|
|
0
|
my $e_mtime = (Ehp15::stat("$realfilename.e"))[9]; |
5334
|
0
|
0
|
0
|
|
|
0
|
my $mtime = (Ehp15::stat($realfilename))[9]; |
5335
|
0
|
|
|
|
|
0
|
my $module_mtime = (Ehp15::stat(__FILE__))[9]; |
5336
|
|
|
|
|
|
|
if (($e_mtime < $mtime) or ($mtime < $module_mtime)) { |
5337
|
|
|
|
|
|
|
Ehp15::unlink "$realfilename.e"; |
5338
|
|
|
|
|
|
|
} |
5339
|
0
|
0
|
|
|
|
0
|
} |
5340
|
0
|
|
|
|
|
0
|
|
5341
|
0
|
0
|
|
|
|
0
|
if (Ehp15::e("$realfilename.e")) { |
5342
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5343
|
0
|
|
|
|
|
0
|
_open_r($fh, "$realfilename.e") or croak "Can't open file: $realfilename.e"; |
5344
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5345
|
|
|
|
|
|
|
CORE::eval q{ |
5346
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5347
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5348
|
|
|
|
|
|
|
}; |
5349
|
0
|
|
|
|
|
0
|
} |
5350
|
0
|
0
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5351
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5352
|
|
|
|
|
|
|
if ($@) { |
5353
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename.e"; |
5354
|
|
|
|
|
|
|
} |
5355
|
0
|
|
|
|
|
0
|
} |
5356
|
|
|
|
|
|
|
else { |
5357
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5358
|
0
|
|
|
|
|
0
|
} |
5359
|
0
|
0
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5360
|
0
|
|
|
|
|
0
|
$script = <$fh>; |
5361
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5362
|
|
|
|
|
|
|
CORE::eval q{ |
5363
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5364
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5365
|
0
|
0
|
|
|
|
0
|
}; |
5366
|
|
|
|
|
|
|
} |
5367
|
|
|
|
|
|
|
close($fh) or croak "Can't close file: $realfilename: $!"; |
5368
|
0
|
|
|
|
|
0
|
} |
5369
|
0
|
0
|
|
|
|
0
|
else { |
5370
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5371
|
0
|
|
|
|
|
0
|
_open_r($fh, $realfilename) or croak "Can't open file: $realfilename"; |
5372
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5373
|
|
|
|
|
|
|
CORE::eval q{ |
5374
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5375
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock($realfilename); |
5376
|
|
|
|
|
|
|
}; |
5377
|
0
|
|
|
|
|
0
|
} |
5378
|
0
|
0
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5379
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH | LOCK_NB) }; |
5380
|
|
|
|
|
|
|
if ($@) { |
5381
|
|
|
|
|
|
|
carp "Can't immediately read-lock the file: $realfilename"; |
5382
|
|
|
|
|
|
|
} |
5383
|
0
|
|
|
|
|
0
|
} |
5384
|
|
|
|
|
|
|
else { |
5385
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_SH) }; |
5386
|
0
|
|
|
|
|
0
|
} |
5387
|
0
|
0
|
|
|
|
0
|
local $/ = undef; # slurp mode |
5388
|
0
|
|
|
|
|
0
|
$script = <$fh>; |
5389
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5390
|
|
|
|
|
|
|
CORE::eval q{ |
5391
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5392
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock($realfilename); |
5393
|
0
|
0
|
|
|
|
0
|
}; |
5394
|
|
|
|
|
|
|
} |
5395
|
0
|
0
|
|
|
|
0
|
close($fh) or croak "Can't close file: $realfilename: $!"; |
5396
|
0
|
|
|
|
|
0
|
|
5397
|
0
|
|
|
|
|
0
|
if ($script =~ /^ (?>\s*) use (?>\s+) HP15 (?>\s*) ([^\x80-\xA0\xE0-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
5398
|
0
|
|
|
|
|
0
|
CORE::require HP15; |
5399
|
0
|
0
|
|
|
|
0
|
$script = HP15::escape_script($script); |
5400
|
0
|
0
|
|
|
|
0
|
my $fh = gensym(); |
|
|
0
|
|
|
|
|
|
5401
|
0
|
|
|
|
|
0
|
open($fh, ">$realfilename.e") or croak "Can't write open file: $realfilename.e"; |
5402
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5403
|
|
|
|
|
|
|
CORE::eval q{ |
5404
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5405
|
|
|
|
|
|
|
Mac::Files::FSpSetFLock("$realfilename.e"); |
5406
|
|
|
|
|
|
|
}; |
5407
|
0
|
|
|
|
|
0
|
} |
5408
|
0
|
0
|
|
|
|
0
|
elsif (exists $ENV{'CHAR_NONBLOCK'}) { |
5409
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX | LOCK_NB) }; |
5410
|
|
|
|
|
|
|
if ($@) { |
5411
|
|
|
|
|
|
|
carp "Can't immediately write-lock the file: $realfilename.e"; |
5412
|
|
|
|
|
|
|
} |
5413
|
0
|
|
|
|
|
0
|
} |
5414
|
|
|
|
|
|
|
else { |
5415
|
0
|
|
|
|
|
0
|
CORE::eval q{ flock($fh, LOCK_EX) }; |
5416
|
0
|
0
|
|
|
|
0
|
} |
5417
|
0
|
|
|
|
|
0
|
CORE::eval q{ truncate($fh, 0) }; |
|
0
|
|
|
|
|
0
|
|
5418
|
0
|
0
|
|
|
|
0
|
seek($fh, 0, 0) or croak "Can't seek file: $realfilename.e"; |
5419
|
0
|
|
|
|
|
0
|
print {$fh} $script; |
5420
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
5421
|
|
|
|
|
|
|
CORE::eval q{ |
5422
|
|
|
|
|
|
|
CORE::require Mac::Files; |
5423
|
|
|
|
|
|
|
Mac::Files::FSpRstFLock("$realfilename.e"); |
5424
|
0
|
0
|
|
|
|
0
|
}; |
5425
|
|
|
|
|
|
|
} |
5426
|
|
|
|
|
|
|
close($fh) or croak "Can't close file: $realfilename: $!"; |
5427
|
|
|
|
|
|
|
} |
5428
|
|
|
|
|
|
|
} |
5429
|
389
|
|
|
389
|
|
4518
|
|
|
389
|
|
|
|
|
5617
|
|
|
389
|
|
|
|
|
428753
|
|
|
0
|
|
|
|
|
0
|
|
5430
|
0
|
|
|
|
|
0
|
{ |
5431
|
|
|
|
|
|
|
no strict; |
5432
|
0
|
|
|
|
|
0
|
$result = scalar CORE::eval $script; |
5433
|
|
|
|
|
|
|
} |
5434
|
|
|
|
|
|
|
last ITER_REQUIRE; |
5435
|
0
|
|
|
|
|
0
|
} |
5436
|
|
|
|
|
|
|
} |
5437
|
|
|
|
|
|
|
croak "Can't find $_ in \@INC"; |
5438
|
0
|
0
|
|
|
|
0
|
} |
|
|
0
|
|
|
|
|
|
5439
|
0
|
|
|
|
|
0
|
|
5440
|
0
|
|
|
|
|
0
|
if ($@) { |
5441
|
|
|
|
|
|
|
$INC{$_} = undef; |
5442
|
|
|
|
|
|
|
croak $@; |
5443
|
0
|
|
|
|
|
0
|
} |
5444
|
0
|
|
|
|
|
0
|
elsif (not $result) { |
5445
|
|
|
|
|
|
|
delete $INC{$_}; |
5446
|
|
|
|
|
|
|
croak "$_ did not return true value"; |
5447
|
0
|
|
|
|
|
0
|
} |
5448
|
|
|
|
|
|
|
else { |
5449
|
|
|
|
|
|
|
return $result; |
5450
|
|
|
|
|
|
|
} |
5451
|
|
|
|
|
|
|
} |
5452
|
|
|
|
|
|
|
|
5453
|
|
|
|
|
|
|
# |
5454
|
|
|
|
|
|
|
# HP-15 telldir avoid warning |
5455
|
|
|
|
|
|
|
# |
5456
|
0
|
|
|
768
|
0
|
0
|
sub Ehp15::telldir(*) { |
5457
|
|
|
|
|
|
|
|
5458
|
768
|
|
|
|
|
2374
|
local $^W = 0; |
5459
|
|
|
|
|
|
|
|
5460
|
|
|
|
|
|
|
return CORE::telldir $_[0]; |
5461
|
|
|
|
|
|
|
} |
5462
|
|
|
|
|
|
|
|
5463
|
|
|
|
|
|
|
# |
5464
|
|
|
|
|
|
|
# ${^PREMATCH}, $PREMATCH, $` the string preceding what was matched |
5465
|
768
|
0
|
|
0
|
0
|
30315
|
# |
5466
|
0
|
0
|
0
|
|
|
0
|
sub Ehp15::PREMATCH { |
5467
|
0
|
|
|
|
|
0
|
if (defined($&)) { |
5468
|
|
|
|
|
|
|
if (defined($1) and (CORE::substr($&,-CORE::length($1),CORE::length($1)) eq $1)) { |
5469
|
|
|
|
|
|
|
return CORE::substr($&,0,CORE::length($&)-CORE::length($1)); |
5470
|
0
|
|
|
|
|
0
|
} |
5471
|
|
|
|
|
|
|
else { |
5472
|
|
|
|
|
|
|
croak 'Use of "$`", $PREMATCH, and ${^PREMATCH} need to /( capture all )/ in regexp'; |
5473
|
|
|
|
|
|
|
} |
5474
|
0
|
|
|
|
|
0
|
} |
5475
|
|
|
|
|
|
|
else { |
5476
|
0
|
|
|
|
|
0
|
return ''; |
5477
|
|
|
|
|
|
|
} |
5478
|
|
|
|
|
|
|
return $`; |
5479
|
|
|
|
|
|
|
} |
5480
|
|
|
|
|
|
|
|
5481
|
|
|
|
|
|
|
# |
5482
|
|
|
|
|
|
|
# ${^MATCH}, $MATCH, $& the string that matched |
5483
|
0
|
0
|
|
0
|
0
|
0
|
# |
5484
|
0
|
0
|
|
|
|
0
|
sub Ehp15::MATCH { |
5485
|
0
|
|
|
|
|
0
|
if (defined($&)) { |
5486
|
|
|
|
|
|
|
if (defined($1)) { |
5487
|
|
|
|
|
|
|
return $1; |
5488
|
0
|
|
|
|
|
0
|
} |
5489
|
|
|
|
|
|
|
else { |
5490
|
|
|
|
|
|
|
croak 'Use of "$&", $MATCH, and ${^MATCH} need to /( capture all )/ in regexp'; |
5491
|
|
|
|
|
|
|
} |
5492
|
0
|
|
|
|
|
0
|
} |
5493
|
|
|
|
|
|
|
else { |
5494
|
0
|
|
|
|
|
0
|
return ''; |
5495
|
|
|
|
|
|
|
} |
5496
|
|
|
|
|
|
|
return $&; |
5497
|
|
|
|
|
|
|
} |
5498
|
|
|
|
|
|
|
|
5499
|
|
|
|
|
|
|
# |
5500
|
|
|
|
|
|
|
# ${^POSTMATCH}, $POSTMATCH, $' the string following what was matched |
5501
|
0
|
|
|
0
|
0
|
0
|
# |
5502
|
|
|
|
|
|
|
sub Ehp15::POSTMATCH { |
5503
|
|
|
|
|
|
|
return $'; |
5504
|
|
|
|
|
|
|
} |
5505
|
|
|
|
|
|
|
|
5506
|
|
|
|
|
|
|
# |
5507
|
|
|
|
|
|
|
# HP-15 character to order (with parameter) |
5508
|
|
|
|
|
|
|
# |
5509
|
0
|
0
|
|
0
|
1
|
0
|
sub HP15::ord(;$) { |
5510
|
|
|
|
|
|
|
|
5511
|
0
|
0
|
|
|
|
0
|
local $_ = shift if @_; |
5512
|
0
|
|
|
|
|
0
|
|
5513
|
0
|
|
|
|
|
0
|
if (/\A ($q_char) /oxms) { |
5514
|
0
|
|
|
|
|
0
|
my @ord = unpack 'C*', $1; |
5515
|
0
|
|
|
|
|
0
|
my $ord = 0; |
5516
|
|
|
|
|
|
|
while (my $o = shift @ord) { |
5517
|
0
|
|
|
|
|
0
|
$ord = $ord * 0x100 + $o; |
5518
|
|
|
|
|
|
|
} |
5519
|
|
|
|
|
|
|
return $ord; |
5520
|
0
|
|
|
|
|
0
|
} |
5521
|
|
|
|
|
|
|
else { |
5522
|
|
|
|
|
|
|
return CORE::ord $_; |
5523
|
|
|
|
|
|
|
} |
5524
|
|
|
|
|
|
|
} |
5525
|
|
|
|
|
|
|
|
5526
|
|
|
|
|
|
|
# |
5527
|
|
|
|
|
|
|
# HP-15 character to order (without parameter) |
5528
|
|
|
|
|
|
|
# |
5529
|
0
|
0
|
|
0
|
0
|
0
|
sub HP15::ord_() { |
5530
|
0
|
|
|
|
|
0
|
|
5531
|
0
|
|
|
|
|
0
|
if (/\A ($q_char) /oxms) { |
5532
|
0
|
|
|
|
|
0
|
my @ord = unpack 'C*', $1; |
5533
|
0
|
|
|
|
|
0
|
my $ord = 0; |
5534
|
|
|
|
|
|
|
while (my $o = shift @ord) { |
5535
|
0
|
|
|
|
|
0
|
$ord = $ord * 0x100 + $o; |
5536
|
|
|
|
|
|
|
} |
5537
|
|
|
|
|
|
|
return $ord; |
5538
|
0
|
|
|
|
|
0
|
} |
5539
|
|
|
|
|
|
|
else { |
5540
|
|
|
|
|
|
|
return CORE::ord $_; |
5541
|
|
|
|
|
|
|
} |
5542
|
|
|
|
|
|
|
} |
5543
|
|
|
|
|
|
|
|
5544
|
|
|
|
|
|
|
# |
5545
|
|
|
|
|
|
|
# HP-15 reverse |
5546
|
|
|
|
|
|
|
# |
5547
|
0
|
0
|
|
0
|
0
|
0
|
sub HP15::reverse(@) { |
5548
|
0
|
|
|
|
|
0
|
|
5549
|
|
|
|
|
|
|
if (wantarray) { |
5550
|
|
|
|
|
|
|
return CORE::reverse @_; |
5551
|
|
|
|
|
|
|
} |
5552
|
|
|
|
|
|
|
else { |
5553
|
|
|
|
|
|
|
|
5554
|
|
|
|
|
|
|
# One of us once cornered Larry in an elevator and asked him what |
5555
|
|
|
|
|
|
|
# problem he was solving with this, but he looked as far off into |
5556
|
|
|
|
|
|
|
# the distance as he could in an elevator and said, "It seemed like |
5557
|
0
|
|
|
|
|
0
|
# a good idea at the time." |
5558
|
|
|
|
|
|
|
|
5559
|
|
|
|
|
|
|
return join '', CORE::reverse(join('',@_) =~ /\G ($q_char) /oxmsg); |
5560
|
|
|
|
|
|
|
} |
5561
|
|
|
|
|
|
|
} |
5562
|
|
|
|
|
|
|
|
5563
|
|
|
|
|
|
|
# |
5564
|
|
|
|
|
|
|
# HP-15 getc (with parameter, without parameter) |
5565
|
|
|
|
|
|
|
# |
5566
|
0
|
|
|
0
|
0
|
0
|
sub HP15::getc(;*@) { |
5567
|
0
|
0
|
|
|
|
0
|
|
5568
|
0
|
0
|
0
|
|
|
0
|
my($package) = caller; |
5569
|
|
|
|
|
|
|
my $fh = @_ ? qualify_to_ref(shift,$package) : \*STDIN; |
5570
|
0
|
|
|
|
|
0
|
croak 'Too many arguments for HP15::getc' if @_ and not wantarray; |
|
0
|
|
|
|
|
0
|
|
5571
|
0
|
|
|
|
|
0
|
|
5572
|
0
|
|
|
|
|
0
|
my @length = sort { $a <=> $b } keys %range_tr; |
5573
|
0
|
|
|
|
|
0
|
my $getc = ''; |
5574
|
0
|
0
|
|
|
|
0
|
for my $length ($length[0] .. $length[-1]) { |
5575
|
0
|
0
|
|
|
|
0
|
$getc .= CORE::getc($fh); |
5576
|
0
|
0
|
|
|
|
0
|
if (exists $range_tr{CORE::length($getc)}) { |
5577
|
|
|
|
|
|
|
if ($getc =~ /\A ${Ehp15::dot_s} \z/oxms) { |
5578
|
|
|
|
|
|
|
return wantarray ? ($getc,@_) : $getc; |
5579
|
|
|
|
|
|
|
} |
5580
|
0
|
0
|
|
|
|
0
|
} |
5581
|
|
|
|
|
|
|
} |
5582
|
|
|
|
|
|
|
return wantarray ? ($getc,@_) : $getc; |
5583
|
|
|
|
|
|
|
} |
5584
|
|
|
|
|
|
|
|
5585
|
|
|
|
|
|
|
# |
5586
|
|
|
|
|
|
|
# HP-15 length by character |
5587
|
|
|
|
|
|
|
# |
5588
|
0
|
0
|
|
0
|
1
|
0
|
sub HP15::length(;$) { |
5589
|
|
|
|
|
|
|
|
5590
|
0
|
|
|
|
|
0
|
local $_ = shift if @_; |
5591
|
0
|
|
|
|
|
0
|
|
5592
|
|
|
|
|
|
|
local @_ = /\G ($q_char) /oxmsg; |
5593
|
|
|
|
|
|
|
return scalar @_; |
5594
|
|
|
|
|
|
|
} |
5595
|
|
|
|
|
|
|
|
5596
|
|
|
|
|
|
|
# |
5597
|
|
|
|
|
|
|
# HP-15 substr by character |
5598
|
|
|
|
|
|
|
# |
5599
|
|
|
|
|
|
|
BEGIN { |
5600
|
|
|
|
|
|
|
|
5601
|
|
|
|
|
|
|
# P.232 The lvalue Attribute |
5602
|
|
|
|
|
|
|
# in Chapter 6: Subroutines |
5603
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
5604
|
|
|
|
|
|
|
|
5605
|
|
|
|
|
|
|
# P.336 The lvalue Attribute |
5606
|
|
|
|
|
|
|
# in Chapter 7: Subroutines |
5607
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5608
|
|
|
|
|
|
|
|
5609
|
|
|
|
|
|
|
# P.144 8.4 Lvalue subroutines |
5610
|
|
|
|
|
|
|
# in Chapter 8: perlsub: Perl subroutines |
5611
|
389
|
50
|
0
|
389
|
1
|
254801
|
# of ISBN-13: 978-1-906966-02-7 The Perl Language Reference Manual (for Perl version 5.12.1) |
|
0
|
0
|
|
0
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
5612
|
|
|
|
|
|
|
|
5613
|
|
|
|
|
|
|
CORE::eval sprintf(<<'END', ($] >= 5.014000) ? ':lvalue' : ''); |
5614
|
|
|
|
|
|
|
# vv----------------------******* |
5615
|
|
|
|
|
|
|
sub HP15::substr($$;$$) %s { |
5616
|
|
|
|
|
|
|
|
5617
|
|
|
|
|
|
|
my @char = $_[0] =~ /\G (?>$q_char) /oxmsg; |
5618
|
|
|
|
|
|
|
|
5619
|
|
|
|
|
|
|
# If the substring is beyond either end of the string, substr() returns the undefined |
5620
|
|
|
|
|
|
|
# value and produces a warning. When used as an lvalue, specifying a substring that |
5621
|
|
|
|
|
|
|
# is entirely outside the string raises an exception. |
5622
|
|
|
|
|
|
|
# http://perldoc.perl.org/functions/substr.html |
5623
|
|
|
|
|
|
|
|
5624
|
|
|
|
|
|
|
# A return with no argument returns the scalar value undef in scalar context, |
5625
|
|
|
|
|
|
|
# an empty list () in list context, and (naturally) nothing at all in void |
5626
|
|
|
|
|
|
|
# context. |
5627
|
|
|
|
|
|
|
|
5628
|
|
|
|
|
|
|
my $offset = $_[1]; |
5629
|
|
|
|
|
|
|
if (($offset > scalar(@char)) or ($offset < (-1 * scalar(@char)))) { |
5630
|
|
|
|
|
|
|
return; |
5631
|
|
|
|
|
|
|
} |
5632
|
|
|
|
|
|
|
|
5633
|
|
|
|
|
|
|
# substr($string,$offset,$length,$replacement) |
5634
|
|
|
|
|
|
|
if (@_ == 4) { |
5635
|
|
|
|
|
|
|
my(undef,undef,$length,$replacement) = @_; |
5636
|
|
|
|
|
|
|
my $substr = join '', splice(@char, $offset, $length, $replacement); |
5637
|
|
|
|
|
|
|
$_[0] = join '', @char; |
5638
|
|
|
|
|
|
|
|
5639
|
|
|
|
|
|
|
# return $substr; this doesn't work, don't say "return" |
5640
|
|
|
|
|
|
|
$substr; |
5641
|
|
|
|
|
|
|
} |
5642
|
|
|
|
|
|
|
|
5643
|
|
|
|
|
|
|
# substr($string,$offset,$length) |
5644
|
|
|
|
|
|
|
elsif (@_ == 3) { |
5645
|
|
|
|
|
|
|
my(undef,undef,$length) = @_; |
5646
|
|
|
|
|
|
|
my $octet_offset = 0; |
5647
|
|
|
|
|
|
|
my $octet_length = 0; |
5648
|
|
|
|
|
|
|
if ($offset == 0) { |
5649
|
|
|
|
|
|
|
$octet_offset = 0; |
5650
|
|
|
|
|
|
|
} |
5651
|
|
|
|
|
|
|
elsif ($offset > 0) { |
5652
|
|
|
|
|
|
|
$octet_offset = CORE::length(join '', @char[0..$offset-1]); |
5653
|
|
|
|
|
|
|
} |
5654
|
|
|
|
|
|
|
else { |
5655
|
|
|
|
|
|
|
$octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]); |
5656
|
|
|
|
|
|
|
} |
5657
|
|
|
|
|
|
|
if ($length == 0) { |
5658
|
|
|
|
|
|
|
$octet_length = 0; |
5659
|
|
|
|
|
|
|
} |
5660
|
|
|
|
|
|
|
elsif ($length > 0) { |
5661
|
|
|
|
|
|
|
$octet_length = CORE::length(join '', @char[$offset..$offset+$length-1]); |
5662
|
|
|
|
|
|
|
} |
5663
|
|
|
|
|
|
|
else { |
5664
|
|
|
|
|
|
|
$octet_length = -1 * CORE::length(join '', @char[$#char+$length+1..$#char]); |
5665
|
|
|
|
|
|
|
} |
5666
|
|
|
|
|
|
|
CORE::substr($_[0], $octet_offset, $octet_length); |
5667
|
|
|
|
|
|
|
} |
5668
|
|
|
|
|
|
|
|
5669
|
|
|
|
|
|
|
# substr($string,$offset) |
5670
|
|
|
|
|
|
|
else { |
5671
|
|
|
|
|
|
|
my $octet_offset = 0; |
5672
|
|
|
|
|
|
|
if ($offset == 0) { |
5673
|
|
|
|
|
|
|
$octet_offset = 0; |
5674
|
|
|
|
|
|
|
} |
5675
|
|
|
|
|
|
|
elsif ($offset > 0) { |
5676
|
|
|
|
|
|
|
$octet_offset = CORE::length(join '', @char[0..$offset-1]); |
5677
|
|
|
|
|
|
|
} |
5678
|
|
|
|
|
|
|
else { |
5679
|
|
|
|
|
|
|
$octet_offset = -1 * CORE::length(join '', @char[$#char+$offset+1..$#char]); |
5680
|
|
|
|
|
|
|
} |
5681
|
|
|
|
|
|
|
CORE::substr($_[0], $octet_offset); |
5682
|
|
|
|
|
|
|
} |
5683
|
|
|
|
|
|
|
} |
5684
|
|
|
|
|
|
|
END |
5685
|
|
|
|
|
|
|
} |
5686
|
|
|
|
|
|
|
|
5687
|
|
|
|
|
|
|
# |
5688
|
|
|
|
|
|
|
# HP-15 index by character |
5689
|
|
|
|
|
|
|
# |
5690
|
0
|
|
|
0
|
1
|
0
|
sub HP15::index($$;$) { |
5691
|
0
|
0
|
|
|
|
0
|
|
5692
|
0
|
|
|
|
|
0
|
my $index; |
5693
|
|
|
|
|
|
|
if (@_ == 3) { |
5694
|
|
|
|
|
|
|
$index = Ehp15::index($_[0], $_[1], CORE::length(HP15::substr($_[0], 0, $_[2]))); |
5695
|
0
|
|
|
|
|
0
|
} |
5696
|
|
|
|
|
|
|
else { |
5697
|
|
|
|
|
|
|
$index = Ehp15::index($_[0], $_[1]); |
5698
|
0
|
0
|
|
|
|
0
|
} |
5699
|
0
|
|
|
|
|
0
|
|
5700
|
|
|
|
|
|
|
if ($index == -1) { |
5701
|
|
|
|
|
|
|
return -1; |
5702
|
0
|
|
|
|
|
0
|
} |
5703
|
|
|
|
|
|
|
else { |
5704
|
|
|
|
|
|
|
return HP15::length(CORE::substr $_[0], 0, $index); |
5705
|
|
|
|
|
|
|
} |
5706
|
|
|
|
|
|
|
} |
5707
|
|
|
|
|
|
|
|
5708
|
|
|
|
|
|
|
# |
5709
|
|
|
|
|
|
|
# HP-15 rindex by character |
5710
|
|
|
|
|
|
|
# |
5711
|
0
|
|
|
0
|
1
|
0
|
sub HP15::rindex($$;$) { |
5712
|
0
|
0
|
|
|
|
0
|
|
5713
|
0
|
|
|
|
|
0
|
my $rindex; |
5714
|
|
|
|
|
|
|
if (@_ == 3) { |
5715
|
|
|
|
|
|
|
$rindex = Ehp15::rindex($_[0], $_[1], CORE::length(HP15::substr($_[0], 0, $_[2]))); |
5716
|
0
|
|
|
|
|
0
|
} |
5717
|
|
|
|
|
|
|
else { |
5718
|
|
|
|
|
|
|
$rindex = Ehp15::rindex($_[0], $_[1]); |
5719
|
0
|
0
|
|
|
|
0
|
} |
5720
|
0
|
|
|
|
|
0
|
|
5721
|
|
|
|
|
|
|
if ($rindex == -1) { |
5722
|
|
|
|
|
|
|
return -1; |
5723
|
0
|
|
|
|
|
0
|
} |
5724
|
|
|
|
|
|
|
else { |
5725
|
|
|
|
|
|
|
return HP15::length(CORE::substr $_[0], 0, $rindex); |
5726
|
|
|
|
|
|
|
} |
5727
|
|
|
|
|
|
|
} |
5728
|
|
|
|
|
|
|
|
5729
|
389
|
|
|
389
|
|
3163
|
# when 'm//', '/' means regexp match 'm//' and '?' means regexp match '??' |
|
389
|
|
|
|
|
3727
|
|
|
389
|
|
|
|
|
42618
|
|
5730
|
|
|
|
|
|
|
# when 'div', '/' means division operator and '?' means conditional operator (condition ? then : else) |
5731
|
|
|
|
|
|
|
use vars qw($slash); $slash = 'm//'; |
5732
|
|
|
|
|
|
|
|
5733
|
|
|
|
|
|
|
# ord() to ord() or HP15::ord() |
5734
|
|
|
|
|
|
|
my $function_ord = 'ord'; |
5735
|
|
|
|
|
|
|
|
5736
|
|
|
|
|
|
|
# ord to ord or HP15::ord_ |
5737
|
|
|
|
|
|
|
my $function_ord_ = 'ord'; |
5738
|
|
|
|
|
|
|
|
5739
|
|
|
|
|
|
|
# reverse to reverse or HP15::reverse |
5740
|
|
|
|
|
|
|
my $function_reverse = 'reverse'; |
5741
|
|
|
|
|
|
|
|
5742
|
|
|
|
|
|
|
# getc to getc or HP15::getc |
5743
|
|
|
|
|
|
|
my $function_getc = 'getc'; |
5744
|
|
|
|
|
|
|
|
5745
|
|
|
|
|
|
|
# P.1023 Appendix W.9 Multibyte Anchoring |
5746
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
5747
|
|
|
|
|
|
|
|
5748
|
|
|
|
|
|
|
my $anchor = ''; |
5749
|
389
|
|
|
389
|
|
6291
|
$anchor = q{${Ehp15::anchor}}; |
|
389
|
|
|
0
|
|
822
|
|
|
389
|
|
|
|
|
22961128
|
|
5750
|
|
|
|
|
|
|
|
5751
|
|
|
|
|
|
|
use vars qw($nest); |
5752
|
|
|
|
|
|
|
|
5753
|
|
|
|
|
|
|
# regexp of nested parens in qqXX |
5754
|
|
|
|
|
|
|
|
5755
|
|
|
|
|
|
|
# P.340 Matching Nested Constructs with Embedded Code |
5756
|
|
|
|
|
|
|
# in Chapter 7: Perl |
5757
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
5758
|
|
|
|
|
|
|
|
5759
|
|
|
|
|
|
|
my $qq_paren = qr{(?{local $nest=0}) (?>(?: |
5760
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\()] | |
5761
|
|
|
|
|
|
|
\( (?{$nest++}) | |
5762
|
|
|
|
|
|
|
\) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5763
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5764
|
|
|
|
|
|
|
\\ [^\x80-\xA0\xE0-\xFEc] | |
5765
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
5766
|
|
|
|
|
|
|
\\ [\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5767
|
|
|
|
|
|
|
[\x00-\xFF] |
5768
|
|
|
|
|
|
|
}xms; |
5769
|
|
|
|
|
|
|
|
5770
|
|
|
|
|
|
|
my $qq_brace = qr{(?{local $nest=0}) (?>(?: |
5771
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\{}] | |
5772
|
|
|
|
|
|
|
\{ (?{$nest++}) | |
5773
|
|
|
|
|
|
|
\} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5774
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5775
|
|
|
|
|
|
|
\\ [^\x80-\xA0\xE0-\xFEc] | |
5776
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
5777
|
|
|
|
|
|
|
\\ [\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5778
|
|
|
|
|
|
|
[\x00-\xFF] |
5779
|
|
|
|
|
|
|
}xms; |
5780
|
|
|
|
|
|
|
|
5781
|
|
|
|
|
|
|
my $qq_bracket = qr{(?{local $nest=0}) (?>(?: |
5782
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\[\]] | |
5783
|
|
|
|
|
|
|
\[ (?{$nest++}) | |
5784
|
|
|
|
|
|
|
\] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5785
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5786
|
|
|
|
|
|
|
\\ [^\x80-\xA0\xE0-\xFEc] | |
5787
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
5788
|
|
|
|
|
|
|
\\ [\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5789
|
|
|
|
|
|
|
[\x00-\xFF] |
5790
|
|
|
|
|
|
|
}xms; |
5791
|
|
|
|
|
|
|
|
5792
|
|
|
|
|
|
|
my $qq_angle = qr{(?{local $nest=0}) (?>(?: |
5793
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\<>] | |
5794
|
|
|
|
|
|
|
\< (?{$nest++}) | |
5795
|
|
|
|
|
|
|
\> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5796
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5797
|
|
|
|
|
|
|
\\ [^\x80-\xA0\xE0-\xFEc] | |
5798
|
|
|
|
|
|
|
\\c[\x40-\x5F] | |
5799
|
|
|
|
|
|
|
\\ [\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5800
|
|
|
|
|
|
|
[\x00-\xFF] |
5801
|
|
|
|
|
|
|
}xms; |
5802
|
|
|
|
|
|
|
|
5803
|
|
|
|
|
|
|
my $qq_scalar = qr{(?: \{ (?:$qq_brace)*? \} | |
5804
|
|
|
|
|
|
|
(?: ::)? (?: |
5805
|
|
|
|
|
|
|
(?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* ) |
5806
|
|
|
|
|
|
|
(?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*) |
5807
|
|
|
|
|
|
|
(?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*) |
5808
|
|
|
|
|
|
|
)) |
5809
|
|
|
|
|
|
|
}xms; |
5810
|
|
|
|
|
|
|
|
5811
|
|
|
|
|
|
|
my $qq_variable = qr{(?: \{ (?:$qq_brace)*? \} | |
5812
|
|
|
|
|
|
|
(?: ::)? (?: |
5813
|
|
|
|
|
|
|
(?>[0-9]+) | |
5814
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFEa-zA-Z_0-9\[\]] | |
5815
|
|
|
|
|
|
|
^[A-Z] | |
5816
|
|
|
|
|
|
|
(?> [a-zA-Z_][a-zA-Z_0-9]* (?: ::[a-zA-Z_][a-zA-Z_0-9]*)* ) |
5817
|
|
|
|
|
|
|
(?>(?: \[ (?: \$\[ | \$\] | $qq_char )*? \] | \{ (?:$qq_brace)*? \} )*) |
5818
|
|
|
|
|
|
|
(?>(?: (?: -> )? (?: [\$\@\%\&\*]\* | \$\#\* | [\@\%]? \[ (?: \$\[ | \$\] | $qq_char )*? \] | [\@\%\*]? \{ (?:$qq_brace)*? \} ) )*) |
5819
|
|
|
|
|
|
|
)) |
5820
|
|
|
|
|
|
|
}xms; |
5821
|
|
|
|
|
|
|
|
5822
|
|
|
|
|
|
|
my $qq_substr = qr{(?> Char::substr | HP15::substr | CORE::substr | substr ) (?>\s*) \( $qq_paren \) |
5823
|
|
|
|
|
|
|
}xms; |
5824
|
|
|
|
|
|
|
|
5825
|
|
|
|
|
|
|
# regexp of nested parens in qXX |
5826
|
|
|
|
|
|
|
my $q_paren = qr{(?{local $nest=0}) (?>(?: |
5827
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE()] | |
5828
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5829
|
|
|
|
|
|
|
\( (?{$nest++}) | |
5830
|
|
|
|
|
|
|
\) (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5831
|
|
|
|
|
|
|
[\x00-\xFF] |
5832
|
|
|
|
|
|
|
}xms; |
5833
|
|
|
|
|
|
|
|
5834
|
|
|
|
|
|
|
my $q_brace = qr{(?{local $nest=0}) (?>(?: |
5835
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\{\}] | |
5836
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5837
|
|
|
|
|
|
|
\{ (?{$nest++}) | |
5838
|
|
|
|
|
|
|
\} (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5839
|
|
|
|
|
|
|
[\x00-\xFF] |
5840
|
|
|
|
|
|
|
}xms; |
5841
|
|
|
|
|
|
|
|
5842
|
|
|
|
|
|
|
my $q_bracket = qr{(?{local $nest=0}) (?>(?: |
5843
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\[\]] | |
5844
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5845
|
|
|
|
|
|
|
\[ (?{$nest++}) | |
5846
|
|
|
|
|
|
|
\] (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5847
|
|
|
|
|
|
|
[\x00-\xFF] |
5848
|
|
|
|
|
|
|
}xms; |
5849
|
|
|
|
|
|
|
|
5850
|
|
|
|
|
|
|
my $q_angle = qr{(?{local $nest=0}) (?>(?: |
5851
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE<>] | |
5852
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
5853
|
|
|
|
|
|
|
\< (?{$nest++}) | |
5854
|
|
|
|
|
|
|
\> (?(?{$nest>0})(?{$nest--})|(?!)))*) (?(?{$nest!=0})(?!)) | |
5855
|
|
|
|
|
|
|
[\x00-\xFF] |
5856
|
|
|
|
|
|
|
}xms; |
5857
|
|
|
|
|
|
|
|
5858
|
|
|
|
|
|
|
my $matched = ''; |
5859
|
|
|
|
|
|
|
my $s_matched = ''; |
5860
|
|
|
|
|
|
|
$matched = q{$Ehp15::matched}; |
5861
|
|
|
|
|
|
|
$s_matched = q{ Ehp15::s_matched();}; |
5862
|
|
|
|
|
|
|
|
5863
|
|
|
|
|
|
|
my $tr_variable = ''; # variable of tr/// |
5864
|
|
|
|
|
|
|
my $sub_variable = ''; # variable of s/// |
5865
|
|
|
|
|
|
|
my $bind_operator = ''; # =~ or !~ |
5866
|
|
|
|
|
|
|
|
5867
|
|
|
|
|
|
|
my @heredoc = (); # here document |
5868
|
|
|
|
|
|
|
my @heredoc_delimiter = (); |
5869
|
|
|
|
|
|
|
my $here_script = ''; # here script |
5870
|
|
|
|
|
|
|
|
5871
|
|
|
|
|
|
|
# |
5872
|
|
|
|
|
|
|
# escape HP-15 script |
5873
|
0
|
50
|
|
384
|
0
|
0
|
# |
5874
|
|
|
|
|
|
|
sub HP15::escape(;$) { |
5875
|
|
|
|
|
|
|
local($_) = $_[0] if @_; |
5876
|
|
|
|
|
|
|
|
5877
|
|
|
|
|
|
|
# P.359 The Study Function |
5878
|
|
|
|
|
|
|
# in Chapter 7: Perl |
5879
|
384
|
|
|
|
|
1316
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
5880
|
|
|
|
|
|
|
|
5881
|
|
|
|
|
|
|
study $_; # Yes, I studied study yesterday. |
5882
|
|
|
|
|
|
|
|
5883
|
|
|
|
|
|
|
# while all script |
5884
|
|
|
|
|
|
|
|
5885
|
|
|
|
|
|
|
# 6.14. Matching from Where the Last Pattern Left Off |
5886
|
|
|
|
|
|
|
# in Chapter 6. Pattern Matching |
5887
|
|
|
|
|
|
|
# of ISBN 0-596-00313-7 Perl Cookbook, 2nd Edition. |
5888
|
|
|
|
|
|
|
# (and so on) |
5889
|
|
|
|
|
|
|
|
5890
|
|
|
|
|
|
|
# one member of Tag-team |
5891
|
|
|
|
|
|
|
# |
5892
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
5893
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
5894
|
|
|
|
|
|
|
# in Chapter 3: Overview of Regular Expression Features and Flavors |
5895
|
|
|
|
|
|
|
# P.255 Use leading anchors |
5896
|
|
|
|
|
|
|
# P.256 Expose ^ and \G at the front expressions |
5897
|
|
|
|
|
|
|
# in Chapter 6: Crafting an Efficient Expression |
5898
|
|
|
|
|
|
|
# P.315 "Tag-team" matching with /gc |
5899
|
|
|
|
|
|
|
# in Chapter 7: Perl |
5900
|
384
|
|
|
|
|
847
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
5901
|
384
|
|
|
|
|
775
|
|
5902
|
384
|
|
|
|
|
1712
|
my $e_script = ''; |
5903
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { # member |
5904
|
|
|
|
|
|
|
$e_script .= HP15::escape_token(); |
5905
|
186553
|
|
|
|
|
293450
|
} |
5906
|
|
|
|
|
|
|
|
5907
|
|
|
|
|
|
|
return $e_script; |
5908
|
|
|
|
|
|
|
} |
5909
|
|
|
|
|
|
|
|
5910
|
|
|
|
|
|
|
# |
5911
|
|
|
|
|
|
|
# escape HP-15 token of script |
5912
|
|
|
|
|
|
|
# |
5913
|
|
|
|
|
|
|
sub HP15::escape_token { |
5914
|
|
|
|
|
|
|
|
5915
|
384
|
|
|
186553
|
0
|
6230
|
# \n output here document |
5916
|
|
|
|
|
|
|
|
5917
|
|
|
|
|
|
|
my $ignore_modules = join('|', qw( |
5918
|
|
|
|
|
|
|
utf8 |
5919
|
|
|
|
|
|
|
bytes |
5920
|
|
|
|
|
|
|
charnames |
5921
|
|
|
|
|
|
|
I18N::Japanese |
5922
|
|
|
|
|
|
|
I18N::Collate |
5923
|
|
|
|
|
|
|
I18N::JExt |
5924
|
|
|
|
|
|
|
File::DosGlob |
5925
|
|
|
|
|
|
|
Wild |
5926
|
|
|
|
|
|
|
Wildcard |
5927
|
|
|
|
|
|
|
Japanese |
5928
|
|
|
|
|
|
|
)); |
5929
|
|
|
|
|
|
|
|
5930
|
|
|
|
|
|
|
# another member of Tag-team |
5931
|
|
|
|
|
|
|
# |
5932
|
|
|
|
|
|
|
# P.315 "Tag-team" matching with /gc |
5933
|
|
|
|
|
|
|
# in Chapter 7: Perl |
5934
|
186553
|
100
|
100
|
|
|
222196
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
5935
|
186553
|
|
|
|
|
14568498
|
|
5936
|
31404
|
100
|
|
|
|
39844
|
if (/\G ( \n ) /oxgc) { # another member (and so on) |
5937
|
31404
|
|
|
|
|
99894
|
my $heredoc = ''; |
5938
|
|
|
|
|
|
|
if (scalar(@heredoc_delimiter) >= 1) { |
5939
|
197
|
|
|
|
|
258
|
$slash = 'm//'; |
5940
|
197
|
|
|
|
|
485
|
|
5941
|
|
|
|
|
|
|
$heredoc = join '', @heredoc; |
5942
|
|
|
|
|
|
|
@heredoc = (); |
5943
|
197
|
|
|
|
|
379
|
|
5944
|
197
|
|
|
|
|
361
|
# skip here document |
5945
|
|
|
|
|
|
|
for my $heredoc_delimiter (@heredoc_delimiter) { |
5946
|
205
|
|
|
|
|
1330
|
/\G .*? \n $heredoc_delimiter \n/xmsgc; |
5947
|
|
|
|
|
|
|
} |
5948
|
197
|
|
|
|
|
360
|
@heredoc_delimiter = (); |
5949
|
|
|
|
|
|
|
|
5950
|
197
|
|
|
|
|
283
|
$here_script = ''; |
5951
|
|
|
|
|
|
|
} |
5952
|
|
|
|
|
|
|
return "\n" . $heredoc; |
5953
|
|
|
|
|
|
|
} |
5954
|
31404
|
|
|
|
|
110440
|
|
5955
|
|
|
|
|
|
|
# ignore space, comment |
5956
|
|
|
|
|
|
|
elsif (/\G ((?>\s+)|\#.*) /oxgc) { return $1; } |
5957
|
|
|
|
|
|
|
|
5958
|
|
|
|
|
|
|
# if (, elsif (, unless (, while (, until (, given (, and when ( |
5959
|
|
|
|
|
|
|
|
5960
|
|
|
|
|
|
|
# given, when |
5961
|
|
|
|
|
|
|
|
5962
|
|
|
|
|
|
|
# P.225 The given Statement |
5963
|
|
|
|
|
|
|
# in Chapter 15: Smart Matching and given-when |
5964
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
5965
|
|
|
|
|
|
|
|
5966
|
|
|
|
|
|
|
# P.133 The given Statement |
5967
|
|
|
|
|
|
|
# in Chapter 4: Statements and Declarations |
5968
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5969
|
42620
|
|
|
|
|
132477
|
|
5970
|
3773
|
|
|
|
|
5858
|
elsif (/\G ( (?: if | elsif | unless | while | until | given | when ) (?>\s*) \( ) /oxgc) { |
5971
|
|
|
|
|
|
|
$slash = 'm//'; |
5972
|
|
|
|
|
|
|
return $1; |
5973
|
|
|
|
|
|
|
} |
5974
|
|
|
|
|
|
|
|
5975
|
|
|
|
|
|
|
# scalar variable ($scalar = ...) =~ tr///; |
5976
|
|
|
|
|
|
|
# scalar variable ($scalar = ...) =~ s///; |
5977
|
|
|
|
|
|
|
|
5978
|
|
|
|
|
|
|
# state |
5979
|
|
|
|
|
|
|
|
5980
|
|
|
|
|
|
|
# P.68 Persistent, Private Variables |
5981
|
|
|
|
|
|
|
# in Chapter 4: Subroutines |
5982
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
5983
|
|
|
|
|
|
|
|
5984
|
|
|
|
|
|
|
# P.160 Persistent Lexically Scoped Variables: state |
5985
|
|
|
|
|
|
|
# in Chapter 4: Statements and Declarations |
5986
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
5987
|
|
|
|
|
|
|
|
5988
|
|
|
|
|
|
|
# (and so on) |
5989
|
3773
|
|
|
|
|
12166
|
|
5990
|
|
|
|
|
|
|
elsif (/\G ( \( (?>\s*) (?: local \b | my \b | our \b | state \b )? (?>\s*) \$ $qq_scalar ) /oxgc) { |
5991
|
170
|
50
|
|
|
|
457
|
my $e_string = e_string($1); |
|
|
50
|
|
|
|
|
|
5992
|
170
|
|
|
|
|
6936
|
|
5993
|
0
|
|
|
|
|
0
|
if (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) { |
5994
|
0
|
|
|
|
|
0
|
$tr_variable = $e_string . e_string($1); |
5995
|
0
|
|
|
|
|
0
|
$bind_operator = $2; |
5996
|
|
|
|
|
|
|
$slash = 'm//'; |
5997
|
|
|
|
|
|
|
return ''; |
5998
|
0
|
|
|
|
|
0
|
} |
5999
|
0
|
|
|
|
|
0
|
elsif (/\G ( (?>\s*) = $qq_paren \) ) ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) { |
6000
|
0
|
|
|
|
|
0
|
$sub_variable = $e_string . e_string($1); |
6001
|
0
|
|
|
|
|
0
|
$bind_operator = $2; |
6002
|
|
|
|
|
|
|
$slash = 'm//'; |
6003
|
|
|
|
|
|
|
return ''; |
6004
|
0
|
|
|
|
|
0
|
} |
6005
|
170
|
|
|
|
|
394
|
else { |
6006
|
|
|
|
|
|
|
$slash = 'div'; |
6007
|
|
|
|
|
|
|
return $e_string; |
6008
|
|
|
|
|
|
|
} |
6009
|
|
|
|
|
|
|
} |
6010
|
|
|
|
|
|
|
|
6011
|
170
|
|
|
|
|
645
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ehp15::PREMATCH() |
6012
|
4
|
|
|
|
|
60
|
elsif (/\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) { |
6013
|
|
|
|
|
|
|
$slash = 'div'; |
6014
|
|
|
|
|
|
|
return q{Ehp15::PREMATCH()}; |
6015
|
|
|
|
|
|
|
} |
6016
|
|
|
|
|
|
|
|
6017
|
4
|
|
|
|
|
21
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ehp15::MATCH() |
6018
|
28
|
|
|
|
|
57
|
elsif (/\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) { |
6019
|
|
|
|
|
|
|
$slash = 'div'; |
6020
|
|
|
|
|
|
|
return q{Ehp15::MATCH()}; |
6021
|
|
|
|
|
|
|
} |
6022
|
|
|
|
|
|
|
|
6023
|
28
|
|
|
|
|
81
|
# $', ${'} --> $', ${'} |
6024
|
1
|
|
|
|
|
2
|
elsif (/\G ( \$' | \$\{'\} ) /oxmsgc) { |
6025
|
|
|
|
|
|
|
$slash = 'div'; |
6026
|
|
|
|
|
|
|
return $1; |
6027
|
|
|
|
|
|
|
} |
6028
|
|
|
|
|
|
|
|
6029
|
1
|
|
|
|
|
4
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ehp15::POSTMATCH() |
6030
|
3
|
|
|
|
|
8
|
elsif (/\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) { |
6031
|
|
|
|
|
|
|
$slash = 'div'; |
6032
|
|
|
|
|
|
|
return q{Ehp15::POSTMATCH()}; |
6033
|
|
|
|
|
|
|
} |
6034
|
|
|
|
|
|
|
|
6035
|
|
|
|
|
|
|
# scalar variable $scalar =~ tr///; |
6036
|
|
|
|
|
|
|
# scalar variable $scalar =~ s///; |
6037
|
|
|
|
|
|
|
# substr() =~ tr///; |
6038
|
3
|
|
|
|
|
11
|
# substr() =~ s///; |
6039
|
|
|
|
|
|
|
elsif (/\G ( \$ $qq_scalar | $qq_substr ) /oxgc) { |
6040
|
2878
|
100
|
|
|
|
7018
|
my $scalar = e_string($1); |
|
|
100
|
|
|
|
|
|
6041
|
2878
|
|
|
|
|
12256
|
|
6042
|
9
|
|
|
|
|
15
|
if (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= (?: tr | y ) \b ) /oxgc) { |
6043
|
9
|
|
|
|
|
18
|
$tr_variable = $scalar; |
6044
|
9
|
|
|
|
|
12
|
$bind_operator = $1; |
6045
|
|
|
|
|
|
|
$slash = 'm//'; |
6046
|
|
|
|
|
|
|
return ''; |
6047
|
9
|
|
|
|
|
21
|
} |
6048
|
253
|
|
|
|
|
419
|
elsif (/\G ( (?>\s*) (?: =~ | !~ ) (?>\s*) ) (?= s \b ) /oxgc) { |
6049
|
253
|
|
|
|
|
571
|
$sub_variable = $scalar; |
6050
|
253
|
|
|
|
|
364
|
$bind_operator = $1; |
6051
|
|
|
|
|
|
|
$slash = 'm//'; |
6052
|
|
|
|
|
|
|
return ''; |
6053
|
253
|
|
|
|
|
699
|
} |
6054
|
2616
|
|
|
|
|
4039
|
else { |
6055
|
|
|
|
|
|
|
$slash = 'div'; |
6056
|
|
|
|
|
|
|
return $scalar; |
6057
|
|
|
|
|
|
|
} |
6058
|
|
|
|
|
|
|
} |
6059
|
|
|
|
|
|
|
|
6060
|
2616
|
|
|
|
|
7457
|
# end of statement |
6061
|
|
|
|
|
|
|
elsif (/\G ( [,;] ) /oxgc) { |
6062
|
|
|
|
|
|
|
$slash = 'm//'; |
6063
|
12209
|
|
|
|
|
18887
|
|
6064
|
|
|
|
|
|
|
# clear tr/// variable |
6065
|
|
|
|
|
|
|
$tr_variable = ''; |
6066
|
12209
|
|
|
|
|
14541
|
|
6067
|
|
|
|
|
|
|
# clear s/// variable |
6068
|
12209
|
|
|
|
|
13809
|
$sub_variable = ''; |
6069
|
|
|
|
|
|
|
|
6070
|
12209
|
|
|
|
|
13511
|
$bind_operator = ''; |
6071
|
|
|
|
|
|
|
|
6072
|
|
|
|
|
|
|
return $1; |
6073
|
|
|
|
|
|
|
} |
6074
|
|
|
|
|
|
|
|
6075
|
12209
|
|
|
|
|
43715
|
# bareword |
6076
|
|
|
|
|
|
|
elsif (/\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) { |
6077
|
|
|
|
|
|
|
return $1; |
6078
|
|
|
|
|
|
|
} |
6079
|
|
|
|
|
|
|
|
6080
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
6081
|
2
|
|
|
|
|
5
|
elsif (/\G ( \$ 0 ) /oxmsgc) { |
6082
|
|
|
|
|
|
|
$slash = 'div'; |
6083
|
|
|
|
|
|
|
return $1; |
6084
|
2
|
|
|
|
|
7
|
} |
6085
|
0
|
|
|
|
|
0
|
elsif (/\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) { |
6086
|
|
|
|
|
|
|
$slash = 'div'; |
6087
|
|
|
|
|
|
|
return $1; |
6088
|
|
|
|
|
|
|
} |
6089
|
|
|
|
|
|
|
|
6090
|
0
|
|
|
|
|
0
|
# $$ --> $$ |
6091
|
1
|
|
|
|
|
3
|
elsif (/\G ( \$ \$ ) (?![\w\{]) /oxmsgc) { |
6092
|
|
|
|
|
|
|
$slash = 'div'; |
6093
|
|
|
|
|
|
|
return $1; |
6094
|
|
|
|
|
|
|
} |
6095
|
|
|
|
|
|
|
|
6096
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
6097
|
1
|
|
|
|
|
9
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
6098
|
219
|
|
|
|
|
387
|
elsif (/\G \$ ((?>[1-9][0-9]*)) /oxmsgc) { |
6099
|
|
|
|
|
|
|
$slash = 'div'; |
6100
|
|
|
|
|
|
|
return e_capture($1); |
6101
|
219
|
|
|
|
|
518
|
} |
6102
|
0
|
|
|
|
|
0
|
elsif (/\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) { |
6103
|
|
|
|
|
|
|
$slash = 'div'; |
6104
|
|
|
|
|
|
|
return e_capture($1); |
6105
|
|
|
|
|
|
|
} |
6106
|
|
|
|
|
|
|
|
6107
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
6108
|
0
|
|
|
|
|
0
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) { |
6109
|
|
|
|
|
|
|
$slash = 'div'; |
6110
|
|
|
|
|
|
|
return e_capture($1.'->'.$2); |
6111
|
|
|
|
|
|
|
} |
6112
|
|
|
|
|
|
|
|
6113
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
6114
|
0
|
|
|
|
|
0
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) { |
6115
|
|
|
|
|
|
|
$slash = 'div'; |
6116
|
|
|
|
|
|
|
return e_capture($1.'->'.$2); |
6117
|
|
|
|
|
|
|
} |
6118
|
|
|
|
|
|
|
|
6119
|
0
|
|
|
|
|
0
|
# $$foo |
6120
|
0
|
|
|
|
|
0
|
elsif (/\G \$ ( \$ (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) { |
6121
|
|
|
|
|
|
|
$slash = 'div'; |
6122
|
|
|
|
|
|
|
return e_capture($1); |
6123
|
|
|
|
|
|
|
} |
6124
|
|
|
|
|
|
|
|
6125
|
0
|
|
|
|
|
0
|
# ${ foo } |
6126
|
0
|
|
|
|
|
0
|
elsif (/\G \$ (?>\s*) \{ ( (?>\s*) (?> [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* ) (?>\s*) ) \} /oxmsgc) { |
6127
|
|
|
|
|
|
|
$slash = 'div'; |
6128
|
|
|
|
|
|
|
return '${' . $1 . '}'; |
6129
|
|
|
|
|
|
|
} |
6130
|
|
|
|
|
|
|
|
6131
|
0
|
|
|
|
|
0
|
# ${ ... } |
6132
|
0
|
|
|
|
|
0
|
elsif (/\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) { |
6133
|
|
|
|
|
|
|
$slash = 'div'; |
6134
|
|
|
|
|
|
|
return e_capture($1); |
6135
|
|
|
|
|
|
|
} |
6136
|
|
|
|
|
|
|
|
6137
|
|
|
|
|
|
|
# variable or function |
6138
|
0
|
|
|
|
|
0
|
# $ @ % & * $ # |
6139
|
605
|
|
|
|
|
1143
|
elsif (/\G ( (?: [\$\@\%\&\*] | \$\# | -> | \b sub \b) (?>\s*) (?: split | chop | index | rindex | lc | uc | fc | chr | ord | reverse | getc | tr | y | q | qq | qx | qw | m | s | qr | glob | lstat | opendir | stat | unlink | chdir ) ) \b /oxmsgc) { |
6140
|
|
|
|
|
|
|
$slash = 'div'; |
6141
|
|
|
|
|
|
|
return $1; |
6142
|
|
|
|
|
|
|
} |
6143
|
|
|
|
|
|
|
# $ $ $ $ $ $ $ $ $ $ $ $ $ $ |
6144
|
605
|
|
|
|
|
2238
|
# $ @ # \ ' " / ? ( ) [ ] < > |
6145
|
103
|
|
|
|
|
206
|
elsif (/\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) { |
6146
|
|
|
|
|
|
|
$slash = 'div'; |
6147
|
|
|
|
|
|
|
return $1; |
6148
|
|
|
|
|
|
|
} |
6149
|
|
|
|
|
|
|
|
6150
|
103
|
|
|
|
|
370
|
# while () |
6151
|
|
|
|
|
|
|
elsif (/\G \b (while (?>\s*) \( (?>\s*) <[\$]?[A-Za-z_][A-Za-z_0-9]*> (?>\s*) \)) \b /oxgc) { |
6152
|
|
|
|
|
|
|
return $1; |
6153
|
|
|
|
|
|
|
} |
6154
|
|
|
|
|
|
|
|
6155
|
|
|
|
|
|
|
# while () --- glob |
6156
|
|
|
|
|
|
|
|
6157
|
|
|
|
|
|
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
6158
|
0
|
|
|
|
|
0
|
|
6159
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) < ((?:[^\x80-\xA0\xE0-\xFE>\0\a\e\f\n\r\t]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])+?) > (?>\s*) \) \b /oxgc) { |
6160
|
|
|
|
|
|
|
return 'while ($_ = Ehp15::glob("' . $1 . '"))'; |
6161
|
|
|
|
|
|
|
} |
6162
|
|
|
|
|
|
|
|
6163
|
0
|
|
|
|
|
0
|
# while (glob) |
6164
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) glob (?>\s*) \) /oxgc) { |
6165
|
|
|
|
|
|
|
return 'while ($_ = Ehp15::glob_)'; |
6166
|
|
|
|
|
|
|
} |
6167
|
|
|
|
|
|
|
|
6168
|
0
|
|
|
|
|
0
|
# while (glob(WILDCARD)) |
6169
|
|
|
|
|
|
|
elsif (/\G \b while (?>\s*) \( (?>\s*) glob \b /oxgc) { |
6170
|
|
|
|
|
|
|
return 'while ($_ = Ehp15::glob'; |
6171
|
|
|
|
|
|
|
} |
6172
|
0
|
|
|
|
|
0
|
|
|
482
|
|
|
|
|
1147
|
|
6173
|
|
|
|
|
|
|
# doit if, doit unless, doit while, doit until, doit for, doit when |
6174
|
|
|
|
|
|
|
elsif (/\G \b ( if | unless | while | until | for | when ) \b /oxgc) { $slash = 'm//'; return $1; } |
6175
|
482
|
|
|
|
|
1952
|
|
|
19
|
|
|
|
|
36
|
|
6176
|
19
|
|
|
|
|
68
|
# subroutines of package Ehp15 |
|
0
|
|
|
|
|
0
|
|
6177
|
0
|
|
|
|
|
0
|
elsif (/\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $slash = 'm//'; return $1; } |
|
13
|
|
|
|
|
18
|
|
6178
|
13
|
|
|
|
|
36
|
elsif (/\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; } |
|
0
|
|
|
|
|
0
|
|
6179
|
0
|
|
|
|
|
0
|
elsif (/\G \b HP15::eval (?= (?>\s*) \{ ) /oxgc) { $slash = 'm//'; return 'eval'; } |
|
114
|
|
|
|
|
168
|
|
6180
|
114
|
|
|
|
|
310
|
elsif (/\G \b Char::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval Char::escape'; } |
|
2
|
|
|
|
|
5
|
|
6181
|
2
|
|
|
|
|
7
|
elsif (/\G \b HP15::eval \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'eval HP15::escape'; } |
|
2
|
|
|
|
|
6
|
|
6182
|
2
|
|
|
|
|
6
|
elsif (/\G \b bytes::substr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'substr'; } |
|
2
|
|
|
|
|
4
|
|
6183
|
2
|
|
|
|
|
6
|
elsif (/\G \b chop \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::chop'; } |
|
0
|
|
|
|
|
0
|
|
6184
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'index'; } |
|
2
|
|
|
|
|
6
|
|
6185
|
2
|
|
|
|
|
6
|
elsif (/\G \b Char::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::index'; } |
|
2
|
|
|
|
|
3
|
|
6186
|
2
|
|
|
|
|
5
|
elsif (/\G \b HP15::index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'HP15::index'; } |
|
2
|
|
|
|
|
4
|
|
6187
|
2
|
|
|
|
|
7
|
elsif (/\G \b index \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::index'; } |
|
0
|
|
|
|
|
0
|
|
6188
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'rindex'; } |
|
2
|
|
|
|
|
5
|
|
6189
|
2
|
|
|
|
|
7
|
elsif (/\G \b Char::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Char::rindex'; } |
|
2
|
|
|
|
|
4
|
|
6190
|
2
|
|
|
|
|
9
|
elsif (/\G \b HP15::rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'HP15::rindex'; } |
|
1
|
|
|
|
|
2
|
|
6191
|
1
|
|
|
|
|
3
|
elsif (/\G \b rindex \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::rindex'; } |
|
0
|
|
|
|
|
0
|
|
6192
|
0
|
|
|
|
|
0
|
elsif (/\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ehp15::lc'; } |
|
0
|
|
|
|
|
0
|
|
6193
|
0
|
|
|
|
|
0
|
elsif (/\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ehp15::lcfirst'; } |
|
0
|
|
|
|
|
0
|
|
6194
|
0
|
|
|
|
|
0
|
elsif (/\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ehp15::uc'; } |
|
3
|
|
|
|
|
5
|
|
6195
|
|
|
|
|
|
|
elsif (/\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ehp15::ucfirst'; } |
6196
|
|
|
|
|
|
|
elsif (/\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ehp15::fc'; } |
6197
|
|
|
|
|
|
|
|
6198
|
|
|
|
|
|
|
# stacked file test operators |
6199
|
|
|
|
|
|
|
|
6200
|
|
|
|
|
|
|
# P.179 File Test Operators |
6201
|
|
|
|
|
|
|
# in Chapter 12: File Tests |
6202
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
6203
|
|
|
|
|
|
|
|
6204
|
|
|
|
|
|
|
# P.106 Named Unary and File Test Operators |
6205
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
6206
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
6207
|
|
|
|
|
|
|
|
6208
|
|
|
|
|
|
|
# (and so on) |
6209
|
3
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
6210
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
6211
|
0
|
|
|
|
|
0
|
(?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_qq('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6212
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6213
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6214
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6215
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
|
1
|
|
|
|
|
3
|
|
6216
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
6217
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; } |
6218
|
1
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
10
|
|
6219
|
5
|
|
|
|
|
18
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
6220
|
0
|
|
|
|
|
0
|
(?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_q ('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6221
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6222
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6223
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6224
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
|
1
|
|
|
|
|
4
|
|
6225
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
6226
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; } |
6227
|
1
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
6228
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6229
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "Ehp15::filetest(qw($1),$2)"; } |
|
0
|
|
|
|
|
0
|
|
6230
|
0
|
|
|
|
|
0
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1),$2)"; } |
|
0
|
|
|
|
|
0
|
|
6231
|
|
|
|
|
|
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) (?= [a-z]+) /oxgc) { $slash = 'm//'; return "Ehp15::filetest qw($1),"; } |
6232
|
0
|
|
|
|
|
0
|
elsif (/\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) ((?>\w+)) /oxgc) { $slash = 'm//'; return "Ehp15::filetest(qw($1),$2)"; } |
|
0
|
|
|
|
|
0
|
|
6233
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6234
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_qq('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6235
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6236
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6237
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6238
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
2
|
|
|
|
|
8
|
|
6239
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
6240
|
2
|
|
|
|
|
10
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; } |
|
103
|
|
|
|
|
186
|
|
6241
|
103
|
|
|
|
|
326
|
|
|
0
|
|
|
|
|
0
|
|
6242
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_q ('', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6243
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6244
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6245
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
0
|
|
|
|
|
0
|
|
6246
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
|
2
|
|
|
|
|
7
|
|
6247
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
6248
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $slash = 'm//'; return "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; } |
6249
|
2
|
|
|
|
|
38
|
|
|
6
|
|
|
|
|
13
|
|
6250
|
6
|
|
|
|
|
29
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6251
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "Ehp15::$1($2)"; } |
|
0
|
|
|
|
|
0
|
|
6252
|
0
|
|
|
|
|
0
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "Ehp15::$1($2)"; } |
|
50
|
|
|
|
|
90
|
|
6253
|
50
|
|
|
|
|
243
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return "Ehp15::$1"; } |
|
2
|
|
|
|
|
5
|
|
6254
|
2
|
|
|
|
|
9
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "Ehp15::$1(::"."$2)"; } |
|
1
|
|
|
|
|
3
|
|
6255
|
1
|
|
|
|
|
4
|
elsif (/\G -(t) (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-t $2"; } |
|
3
|
|
|
|
|
10
|
|
6256
|
|
|
|
|
|
|
elsif (/\G \b lstat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ehp15::lstat'; } |
6257
|
|
|
|
|
|
|
elsif (/\G \b stat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ehp15::stat'; } |
6258
|
3
|
|
|
|
|
11
|
|
|
0
|
|
|
|
|
0
|
|
6259
|
0
|
|
|
|
|
0
|
# "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...") |
|
0
|
|
|
|
|
0
|
|
6260
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $slash = 'm//'; return '-s ' . e_qq('', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6261
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6262
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6263
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6264
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6265
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
6266
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_qq('qq',$1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6267
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6268
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $slash = 'm//'; return '-s ' . e_q ('', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6269
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6270
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6271
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6272
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
|
0
|
|
|
|
|
0
|
|
6273
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
6274
|
|
|
|
|
|
|
elsif (/\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $slash = 'm//'; return '-s ' . e_q ('q', $1,$3,$2); } |
6275
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6276
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)* ) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
6277
|
0
|
|
|
|
|
0
|
{ $slash = 'm//'; return "-s $1"; } |
|
0
|
|
|
|
|
0
|
|
6278
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $slash = 'm//'; return "-s ($1)"; } |
|
0
|
|
|
|
|
0
|
|
6279
|
|
|
|
|
|
|
elsif (/\G -s (?= (?>\s+) [a-z]+) /oxgc) { $slash = 'm//'; return '-s'; } |
6280
|
0
|
|
|
|
|
0
|
elsif (/\G -s (?>\s+) ((?>\w+)) /oxgc) { $slash = 'm//'; return "-s $1"; } |
|
2
|
|
|
|
|
5
|
|
6281
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
5
|
|
6282
|
2
|
|
|
|
|
8
|
elsif (/\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'length'; } |
|
36
|
|
|
|
|
84
|
|
6283
|
36
|
|
|
|
|
256
|
elsif (/\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'chr'; } |
|
2
|
|
|
|
|
5
|
|
6284
|
2
|
|
|
|
|
7
|
elsif (/\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ehp15::chr'; } |
|
2
|
|
|
|
|
7
|
|
6285
|
2
|
|
|
|
|
7
|
elsif (/\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return 'ord'; } |
|
8
|
|
|
|
|
22
|
|
6286
|
8
|
|
|
|
|
33
|
elsif (/\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'div'; return $function_ord; } |
|
0
|
|
|
|
|
0
|
|
6287
|
0
|
|
|
|
|
0
|
elsif (/\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $slash = 'm//'; return 'Ehp15::glob'; } |
|
0
|
|
|
|
|
0
|
|
6288
|
0
|
|
|
|
|
0
|
elsif (/\G \b lc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::lc_'; } |
|
0
|
|
|
|
|
0
|
|
6289
|
0
|
|
|
|
|
0
|
elsif (/\G \b lcfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::lcfirst_'; } |
|
0
|
|
|
|
|
0
|
|
6290
|
0
|
|
|
|
|
0
|
elsif (/\G \b uc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::uc_'; } |
|
0
|
|
|
|
|
0
|
|
6291
|
0
|
|
|
|
|
0
|
elsif (/\G \b ucfirst \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::ucfirst_'; } |
|
0
|
|
|
|
|
0
|
|
6292
|
0
|
|
|
|
|
0
|
elsif (/\G \b fc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::fc_'; } |
|
0
|
|
|
|
|
0
|
|
6293
|
|
|
|
|
|
|
elsif (/\G \b lstat \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::lstat_'; } |
6294
|
0
|
|
|
|
|
0
|
elsif (/\G \b stat \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::stat_'; } |
|
0
|
|
|
|
|
0
|
|
6295
|
|
|
|
|
|
|
elsif (/\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
6296
|
0
|
|
|
|
|
0
|
\b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return "Ehp15::filetest_(qw($1))"; } |
|
0
|
|
|
|
|
0
|
|
6297
|
|
|
|
|
|
|
elsif (/\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) |
6298
|
0
|
|
|
|
|
0
|
\b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return "Ehp15::${1}_"; } |
|
0
|
|
|
|
|
0
|
|
6299
|
|
|
|
|
|
|
|
6300
|
0
|
|
|
|
|
0
|
elsif (/\G -s \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return '-s '; } |
|
0
|
|
|
|
|
0
|
|
6301
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
6302
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::length \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'length'; } |
|
0
|
|
|
|
|
0
|
|
6303
|
0
|
|
|
|
|
0
|
elsif (/\G \b bytes::chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'chr'; } |
|
0
|
|
|
|
|
0
|
|
6304
|
0
|
|
|
|
|
0
|
elsif (/\G \b chr \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::chr_'; } |
|
2
|
|
|
|
|
8
|
|
6305
|
2
|
|
|
|
|
9
|
elsif (/\G \b bytes::ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return 'ord'; } |
|
0
|
|
|
|
|
0
|
|
6306
|
0
|
|
|
|
|
0
|
elsif (/\G \b ord \b (?! (?>\s*) => ) /oxgc) { $slash = 'div'; return $function_ord_; } |
|
4
|
|
|
|
|
10
|
|
6307
|
4
|
|
|
|
|
17
|
elsif (/\G \b glob \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::glob_'; } |
|
8
|
|
|
|
|
24
|
|
6308
|
8
|
|
|
|
|
37
|
elsif (/\G \b reverse \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_reverse; } |
|
2
|
|
|
|
|
6
|
|
6309
|
2
|
|
|
|
|
14
|
elsif (/\G \b getc \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return $function_getc; } |
|
0
|
|
|
|
|
0
|
|
6310
|
0
|
|
|
|
|
0
|
elsif (/\G \b opendir ((?>\s*) \( (?>\s*)) (?=[A-Za-z_]) /oxgc) { $slash = 'm//'; return "Ehp15::opendir$1*"; } |
|
87
|
|
|
|
|
268
|
|
6311
|
|
|
|
|
|
|
elsif (/\G \b opendir ((?>\s+)) (?=[A-Za-z_]) /oxgc) { $slash = 'm//'; return "Ehp15::opendir$1*"; } |
6312
|
|
|
|
|
|
|
elsif (/\G \b unlink \b (?! (?>\s*) => ) /oxgc) { $slash = 'm//'; return 'Ehp15::unlink'; } |
6313
|
|
|
|
|
|
|
|
6314
|
87
|
|
|
|
|
365
|
# chdir |
6315
|
|
|
|
|
|
|
elsif (/\G \b (chdir) \b (?! (?>\s*) => ) /oxgc) { |
6316
|
3
|
|
|
|
|
6
|
$slash = 'm//'; |
6317
|
|
|
|
|
|
|
|
6318
|
3
|
|
|
|
|
5
|
my $e = 'Ehp15::chdir'; |
6319
|
3
|
|
|
|
|
13
|
|
6320
|
|
|
|
|
|
|
while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
6321
|
|
|
|
|
|
|
$e .= $1; |
6322
|
|
|
|
|
|
|
} |
6323
|
3
|
50
|
|
|
|
14
|
|
|
3
|
100
|
|
|
|
216
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6324
|
|
|
|
|
|
|
# end of chdir |
6325
|
|
|
|
|
|
|
if (/\G (?= [,;\)\}\]] ) /oxgc) { return $e; } |
6326
|
0
|
|
|
|
|
0
|
|
6327
|
|
|
|
|
|
|
# chdir scalar value |
6328
|
|
|
|
|
|
|
elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return $e . e_string($1); } |
6329
|
|
|
|
|
|
|
|
6330
|
1
|
0
|
|
|
|
5
|
# chdir qq// |
|
0
|
|
|
|
|
0
|
|
6331
|
|
|
|
|
|
|
elsif (/\G \b (qq) \b /oxgc) { |
6332
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq# # --> qr # # |
6333
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6334
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6335
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6336
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq ( ) --> qr ( ) |
6337
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq { } --> qr { } |
6338
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq [ ] --> qr [ ] |
6339
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq < > --> qr < > |
6340
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_chdir('qq','{','}',$2); } # qq | | --> qr { } |
6341
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_chdir('qq',$1,$3,$2); } # qq * * --> qr * * |
6342
|
|
|
|
|
|
|
} |
6343
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6344
|
|
|
|
|
|
|
} |
6345
|
|
|
|
|
|
|
} |
6346
|
|
|
|
|
|
|
|
6347
|
0
|
0
|
|
|
|
0
|
# chdir q// |
|
0
|
|
|
|
|
0
|
|
6348
|
|
|
|
|
|
|
elsif (/\G \b (q) \b /oxgc) { |
6349
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q# # --> qr # # |
6350
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6351
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6352
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6353
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q ( ) --> qr ( ) |
6354
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q { } --> qr { } |
6355
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q [ ] --> qr [ ] |
6356
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q < > --> qr < > |
6357
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return $e . e_chdir_q('q','{','}',$2); } # q | | --> qr { } |
6358
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return $e . e_chdir_q('q',$1,$3,$2); } # q * * --> qr * * |
6359
|
|
|
|
|
|
|
} |
6360
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6361
|
|
|
|
|
|
|
} |
6362
|
|
|
|
|
|
|
} |
6363
|
|
|
|
|
|
|
|
6364
|
0
|
|
|
|
|
0
|
# chdir '' |
6365
|
2
|
|
|
|
|
6
|
elsif (/\G (\') /oxgc) { |
6366
|
2
|
50
|
|
|
|
6
|
my $q_string = ''; |
|
13
|
50
|
|
|
|
61
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6367
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6368
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6369
|
2
|
|
|
|
|
5
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } |
6370
|
|
|
|
|
|
|
elsif (/\G \' /oxgc) { return $e . e_chdir_q('',"'","'",$q_string); } |
6371
|
11
|
|
|
|
|
24
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6372
|
|
|
|
|
|
|
} |
6373
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6374
|
|
|
|
|
|
|
} |
6375
|
|
|
|
|
|
|
|
6376
|
0
|
|
|
|
|
0
|
# chdir "" |
6377
|
0
|
|
|
|
|
0
|
elsif (/\G (\") /oxgc) { |
6378
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6379
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6380
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6381
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } |
6382
|
|
|
|
|
|
|
elsif (/\G \" /oxgc) { return $e . e_chdir('','"','"',$qq_string); } |
6383
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
6384
|
|
|
|
|
|
|
} |
6385
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6386
|
|
|
|
|
|
|
} |
6387
|
|
|
|
|
|
|
} |
6388
|
|
|
|
|
|
|
|
6389
|
0
|
|
|
|
|
0
|
# split |
6390
|
|
|
|
|
|
|
elsif (/\G \b (split) \b (?! (?>\s*) => ) /oxgc) { |
6391
|
404
|
|
|
|
|
941
|
$slash = 'm//'; |
6392
|
404
|
|
|
|
|
633
|
|
6393
|
404
|
|
|
|
|
1944
|
my $e = ''; |
6394
|
|
|
|
|
|
|
while (/\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
6395
|
|
|
|
|
|
|
$e .= $1; |
6396
|
|
|
|
|
|
|
} |
6397
|
401
|
100
|
|
|
|
1817
|
|
|
404
|
100
|
|
|
|
19028
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6398
|
|
|
|
|
|
|
# end of split |
6399
|
|
|
|
|
|
|
if (/\G (?= [,;\)\}\]] ) /oxgc) { return 'Ehp15::split' . $e; } |
6400
|
3
|
|
|
|
|
16
|
|
6401
|
|
|
|
|
|
|
# split scalar value |
6402
|
|
|
|
|
|
|
elsif (/\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { return 'Ehp15::split' . $e . e_string($1); } |
6403
|
1
|
|
|
|
|
4
|
|
6404
|
0
|
|
|
|
|
0
|
# split literal space |
6405
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq (\#) [ ] (\#) /oxgc) { return 'Ehp15::split' . $e . qq {qq$1 $2}; } |
6406
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Ehp15::split' . $e . qq{$1qq$2 $3}; } |
6407
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Ehp15::split' . $e . qq{$1qq$2 $3}; } |
6408
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Ehp15::split' . $e . qq{$1qq$2 $3}; } |
6409
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Ehp15::split' . $e . qq{$1qq$2 $3}; } |
6410
|
0
|
|
|
|
|
0
|
elsif (/\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Ehp15::split' . $e . qq{$1qq$2 $3}; } |
6411
|
0
|
|
|
|
|
0
|
elsif (/\G \b q (\#) [ ] (\#) /oxgc) { return 'Ehp15::split' . $e . qq {q$1 $2}; } |
6412
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { return 'Ehp15::split' . $e . qq {$1q$2 $3}; } |
6413
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { return 'Ehp15::split' . $e . qq {$1q$2 $3}; } |
6414
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { return 'Ehp15::split' . $e . qq {$1q$2 $3}; } |
6415
|
0
|
|
|
|
|
0
|
elsif (/\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { return 'Ehp15::split' . $e . qq {$1q$2 $3}; } |
6416
|
13
|
|
|
|
|
68
|
elsif (/\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { return 'Ehp15::split' . $e . qq {$1q$2 $3}; } |
6417
|
|
|
|
|
|
|
elsif (/\G ' [ ] ' /oxgc) { return 'Ehp15::split' . $e . qq {' '}; } |
6418
|
|
|
|
|
|
|
elsif (/\G " [ ] " /oxgc) { return 'Ehp15::split' . $e . qq {" "}; } |
6419
|
|
|
|
|
|
|
|
6420
|
2
|
0
|
|
|
|
10
|
# split qq// |
|
0
|
|
|
|
|
0
|
|
6421
|
|
|
|
|
|
|
elsif (/\G \b (qq) \b /oxgc) { |
6422
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq# # --> qr # # |
6423
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6424
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6425
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6426
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq ( ) --> qr ( ) |
6427
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq { } --> qr { } |
6428
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq [ ] --> qr [ ] |
6429
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq < > --> qr < > |
6430
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr','{','}',$2,''); } # qq | | --> qr { } |
6431
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return e_split($e.'qr',$1,$3,$2,''); } # qq * * --> qr * * |
6432
|
|
|
|
|
|
|
} |
6433
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6434
|
|
|
|
|
|
|
} |
6435
|
|
|
|
|
|
|
} |
6436
|
|
|
|
|
|
|
|
6437
|
0
|
50
|
|
|
|
0
|
# split qr// |
|
124
|
|
|
|
|
867
|
|
6438
|
|
|
|
|
|
|
elsif (/\G \b (qr) \b /oxgc) { |
6439
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # qr# # |
6440
|
124
|
50
|
|
|
|
356
|
else { |
|
124
|
50
|
|
|
|
6093
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6441
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6442
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6443
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr ( ) |
6444
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr { } |
6445
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr [ ] |
6446
|
56
|
|
|
|
|
203
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr < > |
6447
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # qr ' ' |
6448
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # qr | | --> qr { } |
6449
|
68
|
|
|
|
|
303
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # qr * * |
6450
|
|
|
|
|
|
|
} |
6451
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6452
|
|
|
|
|
|
|
} |
6453
|
|
|
|
|
|
|
} |
6454
|
|
|
|
|
|
|
|
6455
|
0
|
0
|
|
|
|
0
|
# split q// |
|
0
|
|
|
|
|
0
|
|
6456
|
|
|
|
|
|
|
elsif (/\G \b (q) \b /oxgc) { |
6457
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q# # --> qr # # |
6458
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6459
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6460
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6461
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q ( ) --> qr ( ) |
6462
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q { } --> qr { } |
6463
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q [ ] --> qr [ ] |
6464
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q < > --> qr < > |
6465
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr','{','}',$2,''); } # q | | --> qr { } |
6466
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { return e_split_q($e.'qr',$1,$3,$2,''); } # q * * --> qr * * |
6467
|
|
|
|
|
|
|
} |
6468
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6469
|
|
|
|
|
|
|
} |
6470
|
|
|
|
|
|
|
} |
6471
|
|
|
|
|
|
|
|
6472
|
0
|
50
|
|
|
|
0
|
# split m// |
|
136
|
|
|
|
|
1020
|
|
6473
|
|
|
|
|
|
|
elsif (/\G \b (m) \b /oxgc) { |
6474
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1,$3,$2,$4); } # m# # --> qr # # |
6475
|
136
|
50
|
|
|
|
410
|
else { |
|
136
|
50
|
|
|
|
6749
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6476
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6477
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6478
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m ( ) --> qr ( ) |
6479
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m { } --> qr { } |
6480
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m [ ] --> qr [ ] |
6481
|
56
|
|
|
|
|
416
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m < > --> qr < > |
6482
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return e_split_q($e.'qr',$1, $3, $2,$4); } # m ' ' --> qr ' ' |
6483
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr','{','}',$2,$4); } # m | | --> qr { } |
6484
|
80
|
|
|
|
|
317
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return e_split ($e.'qr',$1, $3, $2,$4); } # m * * --> qr * * |
6485
|
|
|
|
|
|
|
} |
6486
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
6487
|
|
|
|
|
|
|
} |
6488
|
|
|
|
|
|
|
} |
6489
|
|
|
|
|
|
|
|
6490
|
0
|
|
|
|
|
0
|
# split '' |
6491
|
0
|
|
|
|
|
0
|
elsif (/\G (\') /oxgc) { |
6492
|
0
|
0
|
|
|
|
0
|
my $q_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6493
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6494
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6495
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr'' |
6496
|
|
|
|
|
|
|
elsif (/\G \' /oxgc) { return e_split_q($e.q{ qr},"'","'",$q_string,''); } # ' ' --> qr ' ' |
6497
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6498
|
|
|
|
|
|
|
} |
6499
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6500
|
|
|
|
|
|
|
} |
6501
|
|
|
|
|
|
|
|
6502
|
0
|
|
|
|
|
0
|
# split "" |
6503
|
0
|
|
|
|
|
0
|
elsif (/\G (\") /oxgc) { |
6504
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6505
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6506
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6507
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr"" |
6508
|
|
|
|
|
|
|
elsif (/\G \" /oxgc) { return e_split($e.q{ qr},'"','"',$qq_string,''); } # " " --> qr " " |
6509
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
6510
|
|
|
|
|
|
|
} |
6511
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6512
|
|
|
|
|
|
|
} |
6513
|
|
|
|
|
|
|
|
6514
|
0
|
|
|
|
|
0
|
# split // |
6515
|
125
|
|
|
|
|
329
|
elsif (/\G (\/) /oxgc) { |
6516
|
125
|
50
|
|
|
|
357
|
my $regexp = ''; |
|
558
|
50
|
|
|
|
2619
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6517
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6518
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
6519
|
125
|
|
|
|
|
496
|
elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr// |
6520
|
|
|
|
|
|
|
elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_split($e.q{ qr}, '/','/',$regexp,$1); } # / / --> qr / / |
6521
|
433
|
|
|
|
|
1039
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
6522
|
|
|
|
|
|
|
} |
6523
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
6524
|
|
|
|
|
|
|
} |
6525
|
|
|
|
|
|
|
} |
6526
|
|
|
|
|
|
|
|
6527
|
|
|
|
|
|
|
# tr/// or y/// |
6528
|
|
|
|
|
|
|
|
6529
|
|
|
|
|
|
|
# about [cdsrbB]* (/B modifier) |
6530
|
|
|
|
|
|
|
# |
6531
|
|
|
|
|
|
|
# P.559 appendix C |
6532
|
|
|
|
|
|
|
# of ISBN 4-89052-384-7 Programming perl |
6533
|
|
|
|
|
|
|
# (Japanese title is: Perl puroguramingu) |
6534
|
0
|
|
|
|
|
0
|
|
6535
|
|
|
|
|
|
|
elsif (/\G \b ( tr | y ) \b /oxgc) { |
6536
|
|
|
|
|
|
|
my $ope = $1; |
6537
|
11
|
50
|
|
|
|
33
|
|
6538
|
11
|
|
|
|
|
159
|
# $1 $2 $3 $4 $5 $6 |
6539
|
0
|
|
|
|
|
0
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cdsrbB]*) /oxgc) { # tr# # # |
6540
|
|
|
|
|
|
|
my @tr = ($tr_variable,$2); |
6541
|
|
|
|
|
|
|
return e_tr(@tr,'',$4,$6); |
6542
|
0
|
|
|
|
|
0
|
} |
6543
|
11
|
|
|
|
|
21
|
else { |
6544
|
11
|
50
|
|
|
|
31
|
my $e = ''; |
|
11
|
50
|
|
|
|
797
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6545
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6546
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6547
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { |
6548
|
0
|
0
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6549
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6550
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6551
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) ( ) |
6552
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) { } |
6553
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) [ ] |
6554
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) < > |
6555
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr ( ) * * |
6556
|
|
|
|
|
|
|
} |
6557
|
|
|
|
|
|
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6558
|
0
|
|
|
|
|
0
|
} |
6559
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { |
6560
|
0
|
0
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6561
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6562
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6563
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } ( ) |
6564
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } { } |
6565
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } [ ] |
6566
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } < > |
6567
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr { } * * |
6568
|
|
|
|
|
|
|
} |
6569
|
|
|
|
|
|
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6570
|
0
|
|
|
|
|
0
|
} |
6571
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { |
6572
|
0
|
0
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6573
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6574
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6575
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] ( ) |
6576
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] { } |
6577
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] [ ] |
6578
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] < > |
6579
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr [ ] * * |
6580
|
|
|
|
|
|
|
} |
6581
|
|
|
|
|
|
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6582
|
0
|
|
|
|
|
0
|
} |
6583
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { |
6584
|
0
|
0
|
|
|
|
0
|
my @tr = ($tr_variable,$2); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6585
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6586
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6587
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > ( ) |
6588
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > { } |
6589
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > [ ] |
6590
|
|
|
|
|
|
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > < > |
6591
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { return e_tr(@tr,$e,$2,$4); } # tr < > * * |
6592
|
|
|
|
|
|
|
} |
6593
|
|
|
|
|
|
|
die __FILE__, ": Transliteration replacement not terminated\n"; |
6594
|
|
|
|
|
|
|
} |
6595
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 $5 $6 |
6596
|
11
|
|
|
|
|
42
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cdsrbB]*) /oxgc) { # tr * * * |
6597
|
|
|
|
|
|
|
my @tr = ($tr_variable,$2); |
6598
|
|
|
|
|
|
|
return e_tr(@tr,'',$4,$6); |
6599
|
11
|
|
|
|
|
33
|
} |
6600
|
|
|
|
|
|
|
} |
6601
|
|
|
|
|
|
|
die __FILE__, ": Transliteration pattern not terminated\n"; |
6602
|
|
|
|
|
|
|
} |
6603
|
|
|
|
|
|
|
} |
6604
|
|
|
|
|
|
|
|
6605
|
0
|
|
|
|
|
0
|
# qq// |
6606
|
|
|
|
|
|
|
elsif (/\G \b (qq) \b /oxgc) { |
6607
|
|
|
|
|
|
|
my $ope = $1; |
6608
|
5897
|
100
|
|
|
|
15922
|
|
6609
|
5897
|
|
|
|
|
11740
|
# if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { return e_qq($ope,$1,$3,$2); } # qq# # |
6610
|
40
|
|
|
|
|
64
|
if (/\G (\#) /oxgc) { # qq# # |
6611
|
40
|
100
|
|
|
|
104
|
my $qq_string = ''; |
|
1948
|
50
|
|
|
|
8651
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6612
|
80
|
|
|
|
|
145
|
while (not /\G \z/oxgc) { |
6613
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6614
|
40
|
|
|
|
|
119
|
elsif (/\G (\\\#) /oxgc) { $qq_string .= $1; } |
6615
|
|
|
|
|
|
|
elsif (/\G (\#) /oxgc) { return e_qq($ope,'#','#',$qq_string); } |
6616
|
1828
|
|
|
|
|
3834
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6617
|
|
|
|
|
|
|
} |
6618
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6619
|
|
|
|
|
|
|
} |
6620
|
0
|
|
|
|
|
0
|
|
6621
|
5857
|
|
|
|
|
7956
|
else { |
6622
|
5857
|
50
|
|
|
|
14147
|
my $e = ''; |
|
5857
|
50
|
|
|
|
22960
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6623
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6624
|
|
|
|
|
|
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6625
|
|
|
|
|
|
|
|
6626
|
0
|
|
|
|
|
0
|
# elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq ( ) |
6627
|
0
|
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { # qq ( ) |
6628
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
6629
|
0
|
0
|
|
|
|
0
|
local $nest = 1; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6630
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6631
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6632
|
|
|
|
|
|
|
elsif (/\G (\\\)) /oxgc) { $qq_string .= $1; } |
6633
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { $qq_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
6634
|
0
|
|
|
|
|
0
|
elsif (/\G (\)) /oxgc) { |
6635
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_qq($ope,'(',')',$qq_string); } |
6636
|
0
|
|
|
|
|
0
|
else { $qq_string .= $1; } |
6637
|
|
|
|
|
|
|
} |
6638
|
0
|
|
|
|
|
0
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6639
|
|
|
|
|
|
|
} |
6640
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6641
|
|
|
|
|
|
|
} |
6642
|
|
|
|
|
|
|
|
6643
|
0
|
|
|
|
|
0
|
# elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq { } |
6644
|
5775
|
|
|
|
|
8392
|
elsif (/\G (\{) /oxgc) { # qq { } |
6645
|
5775
|
|
|
|
|
8332
|
my $qq_string = ''; |
6646
|
5775
|
100
|
|
|
|
11966
|
local $nest = 1; |
|
245934
|
50
|
|
|
|
784355
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6647
|
720
|
|
|
|
|
1461
|
while (not /\G \z/oxgc) { |
6648
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
1384
|
|
|
|
|
1988
|
|
6649
|
|
|
|
|
|
|
elsif (/\G (\\\}) /oxgc) { $qq_string .= $1; } |
6650
|
1384
|
100
|
|
|
|
2412
|
elsif (/\G (\{) /oxgc) { $qq_string .= $1; $nest++; } |
|
7159
|
|
|
|
|
11607
|
|
6651
|
5775
|
|
|
|
|
12523
|
elsif (/\G (\}) /oxgc) { |
6652
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_qq($ope,'{','}',$qq_string); } |
6653
|
1384
|
|
|
|
|
2763
|
else { $qq_string .= $1; } |
6654
|
|
|
|
|
|
|
} |
6655
|
236671
|
|
|
|
|
497246
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6656
|
|
|
|
|
|
|
} |
6657
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6658
|
|
|
|
|
|
|
} |
6659
|
|
|
|
|
|
|
|
6660
|
0
|
|
|
|
|
0
|
# elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq [ ] |
6661
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { # qq [ ] |
6662
|
0
|
|
|
|
|
0
|
my $qq_string = ''; |
6663
|
0
|
0
|
|
|
|
0
|
local $nest = 1; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6664
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6665
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6666
|
|
|
|
|
|
|
elsif (/\G (\\\]) /oxgc) { $qq_string .= $1; } |
6667
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { $qq_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
6668
|
0
|
|
|
|
|
0
|
elsif (/\G (\]) /oxgc) { |
6669
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_qq($ope,'[',']',$qq_string); } |
6670
|
0
|
|
|
|
|
0
|
else { $qq_string .= $1; } |
6671
|
|
|
|
|
|
|
} |
6672
|
0
|
|
|
|
|
0
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6673
|
|
|
|
|
|
|
} |
6674
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6675
|
|
|
|
|
|
|
} |
6676
|
|
|
|
|
|
|
|
6677
|
0
|
|
|
|
|
0
|
# elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq < > |
6678
|
62
|
|
|
|
|
123
|
elsif (/\G (\<) /oxgc) { # qq < > |
6679
|
62
|
|
|
|
|
105
|
my $qq_string = ''; |
6680
|
62
|
100
|
|
|
|
164
|
local $nest = 1; |
|
2040
|
50
|
|
|
|
7700
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6681
|
22
|
|
|
|
|
52
|
while (not /\G \z/oxgc) { |
6682
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
2
|
|
|
|
|
4
|
|
6683
|
|
|
|
|
|
|
elsif (/\G (\\\>) /oxgc) { $qq_string .= $1; } |
6684
|
2
|
100
|
|
|
|
3
|
elsif (/\G (\<) /oxgc) { $qq_string .= $1; $nest++; } |
|
64
|
|
|
|
|
152
|
|
6685
|
62
|
|
|
|
|
164
|
elsif (/\G (\>) /oxgc) { |
6686
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_qq($ope,'<','>',$qq_string); } |
6687
|
2
|
|
|
|
|
5
|
else { $qq_string .= $1; } |
6688
|
|
|
|
|
|
|
} |
6689
|
1952
|
|
|
|
|
4045
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6690
|
|
|
|
|
|
|
} |
6691
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6692
|
|
|
|
|
|
|
} |
6693
|
|
|
|
|
|
|
|
6694
|
0
|
|
|
|
|
0
|
# elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qq * * |
6695
|
20
|
|
|
|
|
31
|
elsif (/\G (\S) /oxgc) { # qq * * |
6696
|
20
|
|
|
|
|
22
|
my $delimiter = $1; |
6697
|
20
|
50
|
|
|
|
35
|
my $qq_string = ''; |
|
840
|
50
|
|
|
|
2361
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6698
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6699
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
6700
|
20
|
|
|
|
|
37
|
elsif (/\G (\\\Q$delimiter\E) /oxgc) { $qq_string .= $1; } |
6701
|
|
|
|
|
|
|
elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_qq($ope,$delimiter,$delimiter,$qq_string); } |
6702
|
820
|
|
|
|
|
1522
|
elsif (/\G ($qq_char) /oxgc) { $qq_string .= $1; } |
6703
|
|
|
|
|
|
|
} |
6704
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6705
|
0
|
|
|
|
|
0
|
} |
6706
|
|
|
|
|
|
|
} |
6707
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6708
|
|
|
|
|
|
|
} |
6709
|
|
|
|
|
|
|
} |
6710
|
|
|
|
|
|
|
|
6711
|
0
|
|
|
|
|
0
|
# qr// |
6712
|
184
|
50
|
|
|
|
455
|
elsif (/\G \b (qr) \b /oxgc) { |
6713
|
184
|
|
|
|
|
814
|
my $ope = $1; |
6714
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { # qr# # # |
6715
|
|
|
|
|
|
|
return e_qr($ope,$1,$3,$2,$4); |
6716
|
0
|
|
|
|
|
0
|
} |
6717
|
184
|
|
|
|
|
269
|
else { |
6718
|
184
|
50
|
|
|
|
433
|
my $e = ''; |
|
184
|
50
|
|
|
|
5146
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6719
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6720
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6721
|
1
|
|
|
|
|
7
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr ( ) |
6722
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr { } |
6723
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr [ ] |
6724
|
76
|
|
|
|
|
235
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr < > |
6725
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # qr ' ' |
6726
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # qr | | --> qr { } |
6727
|
107
|
|
|
|
|
301
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # qr * * |
6728
|
|
|
|
|
|
|
} |
6729
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6730
|
|
|
|
|
|
|
} |
6731
|
|
|
|
|
|
|
} |
6732
|
|
|
|
|
|
|
|
6733
|
0
|
|
|
|
|
0
|
# qw// |
6734
|
34
|
50
|
|
|
|
124
|
elsif (/\G \b (qw) \b /oxgc) { |
6735
|
34
|
|
|
|
|
111
|
my $ope = $1; |
6736
|
|
|
|
|
|
|
if (/\G (\#) (.*?) (\#) /oxmsgc) { # qw# # |
6737
|
|
|
|
|
|
|
return e_qw($ope,$1,$3,$2); |
6738
|
0
|
|
|
|
|
0
|
} |
6739
|
34
|
|
|
|
|
71
|
else { |
6740
|
34
|
50
|
|
|
|
126
|
my $e = ''; |
|
34
|
50
|
|
|
|
254
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6741
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6742
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6743
|
34
|
|
|
|
|
123
|
|
6744
|
|
|
|
|
|
|
elsif (/\G (\() ([^(]*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( ) |
6745
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$q_paren)*?) (\)) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw ( ) |
6746
|
0
|
|
|
|
|
0
|
|
6747
|
|
|
|
|
|
|
elsif (/\G (\{) ([^{]*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { } |
6748
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$q_brace)*?) (\}) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw { } |
6749
|
0
|
|
|
|
|
0
|
|
6750
|
|
|
|
|
|
|
elsif (/\G (\[) ([^[]*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ] |
6751
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$q_bracket)*?) (\]) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw [ ] |
6752
|
0
|
|
|
|
|
0
|
|
6753
|
|
|
|
|
|
|
elsif (/\G (\<) ([^<]*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < > |
6754
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$q_angle)*?) (\>) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw < > |
6755
|
0
|
|
|
|
|
0
|
|
6756
|
|
|
|
|
|
|
elsif (/\G ([\x21-\x3F]) (.*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * * |
6757
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$q_char)*?) (\1) /oxmsgc) { return $e . e_qw($ope,$1,$3,$2); } # qw * * |
6758
|
|
|
|
|
|
|
} |
6759
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6760
|
|
|
|
|
|
|
} |
6761
|
|
|
|
|
|
|
} |
6762
|
|
|
|
|
|
|
|
6763
|
0
|
|
|
|
|
0
|
# qx// |
6764
|
3
|
50
|
|
|
|
12
|
elsif (/\G \b (qx) \b /oxgc) { |
6765
|
3
|
|
|
|
|
79
|
my $ope = $1; |
6766
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# # |
6767
|
|
|
|
|
|
|
return e_qq($ope,$1,$3,$2); |
6768
|
0
|
|
|
|
|
0
|
} |
6769
|
3
|
|
|
|
|
8
|
else { |
6770
|
3
|
50
|
|
|
|
14
|
my $e = ''; |
|
3
|
50
|
|
|
|
395
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6771
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6772
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6773
|
2
|
|
|
|
|
9
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx ( ) |
6774
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx { } |
6775
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx [ ] |
6776
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx < > |
6777
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') /oxgc) { return $e . e_q ($ope,$1,$3,$2); } # qx ' ' |
6778
|
1
|
|
|
|
|
4
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { return $e . e_qq($ope,$1,$3,$2); } # qx * * |
6779
|
|
|
|
|
|
|
} |
6780
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6781
|
|
|
|
|
|
|
} |
6782
|
|
|
|
|
|
|
} |
6783
|
|
|
|
|
|
|
|
6784
|
0
|
|
|
|
|
0
|
# q// |
6785
|
|
|
|
|
|
|
elsif (/\G \b (q) \b /oxgc) { |
6786
|
|
|
|
|
|
|
my $ope = $1; |
6787
|
|
|
|
|
|
|
|
6788
|
|
|
|
|
|
|
# if (/\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { return e_q($ope,$1,$3,$2); } # q# # |
6789
|
|
|
|
|
|
|
|
6790
|
|
|
|
|
|
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
6791
|
606
|
50
|
|
|
|
2172
|
# (and so on) |
6792
|
606
|
|
|
|
|
1901
|
|
6793
|
0
|
|
|
|
|
0
|
if (/\G (\#) /oxgc) { # q# # |
6794
|
0
|
0
|
|
|
|
0
|
my $q_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6795
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6796
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6797
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\#) /oxgc) { $q_string .= $1; } |
6798
|
|
|
|
|
|
|
elsif (/\G (\#) /oxgc) { return e_q($ope,'#','#',$q_string); } |
6799
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6800
|
|
|
|
|
|
|
} |
6801
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6802
|
|
|
|
|
|
|
} |
6803
|
0
|
|
|
|
|
0
|
|
6804
|
606
|
|
|
|
|
1132
|
else { |
6805
|
606
|
50
|
|
|
|
2006
|
my $e = ''; |
|
606
|
100
|
|
|
|
3848
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6806
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6807
|
|
|
|
|
|
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6808
|
|
|
|
|
|
|
|
6809
|
0
|
|
|
|
|
0
|
# elsif (/\G (\() ((?:\\\)|\\\\|$q_paren)*?) (\)) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q ( ) |
6810
|
1
|
|
|
|
|
2
|
elsif (/\G (\() /oxgc) { # q ( ) |
6811
|
1
|
|
|
|
|
2
|
my $q_string = ''; |
6812
|
1
|
50
|
|
|
|
3
|
local $nest = 1; |
|
7
|
50
|
|
|
|
50
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6813
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6814
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6815
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\)) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6816
|
|
|
|
|
|
|
elsif (/\G (\\\() /oxgc) { $q_string .= $1; } |
6817
|
0
|
50
|
|
|
|
0
|
elsif (/\G (\() /oxgc) { $q_string .= $1; $nest++; } |
|
1
|
|
|
|
|
3
|
|
6818
|
1
|
|
|
|
|
3
|
elsif (/\G (\)) /oxgc) { |
6819
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_q($ope,'(',')',$q_string); } |
6820
|
0
|
|
|
|
|
0
|
else { $q_string .= $1; } |
6821
|
|
|
|
|
|
|
} |
6822
|
6
|
|
|
|
|
15
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6823
|
|
|
|
|
|
|
} |
6824
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6825
|
|
|
|
|
|
|
} |
6826
|
|
|
|
|
|
|
|
6827
|
0
|
|
|
|
|
0
|
# elsif (/\G (\{) ((?:\\\}|\\\\|$q_brace)*?) (\}) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q { } |
6828
|
599
|
|
|
|
|
1175
|
elsif (/\G (\{) /oxgc) { # q { } |
6829
|
599
|
|
|
|
|
1163
|
my $q_string = ''; |
6830
|
599
|
50
|
|
|
|
1829
|
local $nest = 1; |
|
8202
|
50
|
|
|
|
36414
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6831
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6832
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6833
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\}) /oxgc) { $q_string .= $1; } |
|
114
|
|
|
|
|
189
|
|
6834
|
|
|
|
|
|
|
elsif (/\G (\\\{) /oxgc) { $q_string .= $1; } |
6835
|
114
|
100
|
|
|
|
224
|
elsif (/\G (\{) /oxgc) { $q_string .= $1; $nest++; } |
|
713
|
|
|
|
|
1698
|
|
6836
|
599
|
|
|
|
|
2091
|
elsif (/\G (\}) /oxgc) { |
6837
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_q($ope,'{','}',$q_string); } |
6838
|
114
|
|
|
|
|
258
|
else { $q_string .= $1; } |
6839
|
|
|
|
|
|
|
} |
6840
|
7375
|
|
|
|
|
14619
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6841
|
|
|
|
|
|
|
} |
6842
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6843
|
|
|
|
|
|
|
} |
6844
|
|
|
|
|
|
|
|
6845
|
0
|
|
|
|
|
0
|
# elsif (/\G (\[) ((?:\\\]|\\\\|$q_bracket)*?) (\]) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q [ ] |
6846
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { # q [ ] |
6847
|
0
|
|
|
|
|
0
|
my $q_string = ''; |
6848
|
0
|
0
|
|
|
|
0
|
local $nest = 1; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6849
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6850
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6851
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\]) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6852
|
|
|
|
|
|
|
elsif (/\G (\\\[) /oxgc) { $q_string .= $1; } |
6853
|
0
|
0
|
|
|
|
0
|
elsif (/\G (\[) /oxgc) { $q_string .= $1; $nest++; } |
|
0
|
|
|
|
|
0
|
|
6854
|
0
|
|
|
|
|
0
|
elsif (/\G (\]) /oxgc) { |
6855
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_q($ope,'[',']',$q_string); } |
6856
|
0
|
|
|
|
|
0
|
else { $q_string .= $1; } |
6857
|
|
|
|
|
|
|
} |
6858
|
0
|
|
|
|
|
0
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6859
|
|
|
|
|
|
|
} |
6860
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6861
|
|
|
|
|
|
|
} |
6862
|
|
|
|
|
|
|
|
6863
|
0
|
|
|
|
|
0
|
# elsif (/\G (\<) ((?:\\\>|\\\\|$q_angle)*?) (\>) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q < > |
6864
|
5
|
|
|
|
|
11
|
elsif (/\G (\<) /oxgc) { # q < > |
6865
|
5
|
|
|
|
|
13
|
my $q_string = ''; |
6866
|
5
|
50
|
|
|
|
218
|
local $nest = 1; |
|
82
|
50
|
|
|
|
417
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6867
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6868
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6869
|
0
|
|
|
|
|
0
|
elsif (/\G (\\\>) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
6870
|
|
|
|
|
|
|
elsif (/\G (\\\<) /oxgc) { $q_string .= $1; } |
6871
|
0
|
50
|
|
|
|
0
|
elsif (/\G (\<) /oxgc) { $q_string .= $1; $nest++; } |
|
5
|
|
|
|
|
14
|
|
6872
|
5
|
|
|
|
|
17
|
elsif (/\G (\>) /oxgc) { |
6873
|
|
|
|
|
|
|
if (--$nest == 0) { return $e . e_q($ope,'<','>',$q_string); } |
6874
|
0
|
|
|
|
|
0
|
else { $q_string .= $1; } |
6875
|
|
|
|
|
|
|
} |
6876
|
77
|
|
|
|
|
150
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6877
|
|
|
|
|
|
|
} |
6878
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6879
|
|
|
|
|
|
|
} |
6880
|
|
|
|
|
|
|
|
6881
|
0
|
|
|
|
|
0
|
# elsif (/\G (\S) ((?:\\\1|\\\\|$q_char)*?) (\1) /oxgc) { return $e . e_q($ope,$1,$3,$2); } # q * * |
6882
|
1
|
|
|
|
|
3
|
elsif (/\G (\S) /oxgc) { # q * * |
6883
|
1
|
|
|
|
|
2
|
my $delimiter = $1; |
6884
|
1
|
50
|
|
|
|
4
|
my $q_string = ''; |
|
14
|
50
|
|
|
|
78
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6885
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6886
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
6887
|
1
|
|
|
|
|
3
|
elsif (/\G (\\\Q$delimiter\E) /oxgc) { $q_string .= $1; } |
6888
|
|
|
|
|
|
|
elsif (/\G (\Q$delimiter\E) /oxgc) { return $e . e_q($ope,$delimiter,$delimiter,$q_string); } |
6889
|
13
|
|
|
|
|
29
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
6890
|
|
|
|
|
|
|
} |
6891
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6892
|
0
|
|
|
|
|
0
|
} |
6893
|
|
|
|
|
|
|
} |
6894
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
6895
|
|
|
|
|
|
|
} |
6896
|
|
|
|
|
|
|
} |
6897
|
|
|
|
|
|
|
|
6898
|
0
|
|
|
|
|
0
|
# m// |
6899
|
491
|
50
|
|
|
|
1370
|
elsif (/\G \b (m) \b /oxgc) { |
6900
|
491
|
|
|
|
|
3113
|
my $ope = $1; |
6901
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { # m# # |
6902
|
|
|
|
|
|
|
return e_qr($ope,$1,$3,$2,$4); |
6903
|
0
|
|
|
|
|
0
|
} |
6904
|
491
|
|
|
|
|
732
|
else { |
6905
|
491
|
50
|
|
|
|
1376
|
my $e = ''; |
|
491
|
50
|
|
|
|
19855
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6906
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
6907
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6908
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ( ) |
6909
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m { } |
6910
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m [ ] |
6911
|
92
|
|
|
|
|
245
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m < > |
6912
|
87
|
|
|
|
|
390
|
elsif (/\G (\?) ((?:$qq_char)*?) (\?) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m ? ? |
6913
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr_q($ope,$1, $3, $2,$4); } # m ' ' |
6914
|
|
|
|
|
|
|
elsif (/\G ([*\-:\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,'{','}',$2,$4); } # m | | --> m { } |
6915
|
312
|
|
|
|
|
973
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { return $e . e_qr ($ope,$1, $3, $2,$4); } # m * * |
6916
|
|
|
|
|
|
|
} |
6917
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
6918
|
|
|
|
|
|
|
} |
6919
|
|
|
|
|
|
|
} |
6920
|
|
|
|
|
|
|
|
6921
|
|
|
|
|
|
|
# s/// |
6922
|
|
|
|
|
|
|
|
6923
|
|
|
|
|
|
|
# about [cegimosxpradlunbB]* (/cg modifier) |
6924
|
|
|
|
|
|
|
# |
6925
|
|
|
|
|
|
|
# P.67 Pattern-Matching Operators |
6926
|
|
|
|
|
|
|
# of ISBN 0-596-00241-6 Perl in a Nutshell, Second Edition. |
6927
|
0
|
|
|
|
|
0
|
|
6928
|
|
|
|
|
|
|
elsif (/\G \b (s) \b /oxgc) { |
6929
|
|
|
|
|
|
|
my $ope = $1; |
6930
|
290
|
100
|
|
|
|
861
|
|
6931
|
290
|
|
|
|
|
4540
|
# $1 $2 $3 $4 $5 $6 |
6932
|
|
|
|
|
|
|
if (/\G (\#) ((?:$qq_char)*?) (\#) ((?:$qq_char)*?) (\#) ([cegimosxpradlunbB]*) /oxgc) { # s# # # |
6933
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
6934
|
1
|
|
|
|
|
6
|
} |
6935
|
289
|
|
|
|
|
555
|
else { |
6936
|
289
|
50
|
|
|
|
888
|
my $e = ''; |
|
289
|
50
|
|
|
|
28989
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
6937
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6938
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6939
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { |
6940
|
0
|
0
|
|
|
|
0
|
my @s = ($1,$2,$3); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6941
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6942
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6943
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
6944
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6945
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6946
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6947
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6948
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6949
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6950
|
0
|
|
|
|
|
0
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6951
|
|
|
|
|
|
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6952
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6953
|
|
|
|
|
|
|
} |
6954
|
|
|
|
|
|
|
die __FILE__, ": Substitution replacement not terminated\n"; |
6955
|
0
|
|
|
|
|
0
|
} |
6956
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { |
6957
|
0
|
0
|
|
|
|
0
|
my @s = ($1,$2,$3); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6958
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6959
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6960
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
6961
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6962
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6963
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6964
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6965
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6966
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6967
|
0
|
|
|
|
|
0
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6968
|
|
|
|
|
|
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6969
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6970
|
|
|
|
|
|
|
} |
6971
|
|
|
|
|
|
|
die __FILE__, ": Substitution replacement not terminated\n"; |
6972
|
0
|
|
|
|
|
0
|
} |
6973
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { |
6974
|
0
|
0
|
|
|
|
0
|
my @s = ($1,$2,$3); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6975
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6976
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6977
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
6978
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6979
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6980
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6981
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6982
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6983
|
|
|
|
|
|
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6984
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6985
|
|
|
|
|
|
|
} |
6986
|
|
|
|
|
|
|
die __FILE__, ": Substitution replacement not terminated\n"; |
6987
|
0
|
|
|
|
|
0
|
} |
6988
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { |
6989
|
0
|
0
|
|
|
|
0
|
my @s = ($1,$2,$3); |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
6990
|
|
|
|
|
|
|
while (not /\G \z/oxgc) { |
6991
|
0
|
|
|
|
|
0
|
if (/\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
6992
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 |
6993
|
0
|
|
|
|
|
0
|
elsif (/\G (\() ((?:$qq_paren)*?) (\)) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6994
|
0
|
|
|
|
|
0
|
elsif (/\G (\{) ((?:$qq_brace)*?) (\}) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6995
|
0
|
|
|
|
|
0
|
elsif (/\G (\[) ((?:$qq_bracket)*?) (\]) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6996
|
0
|
|
|
|
|
0
|
elsif (/\G (\<) ((?:$qq_angle)*?) (\>) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6997
|
0
|
|
|
|
|
0
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6998
|
0
|
|
|
|
|
0
|
elsif (/\G (\$) ((?:$qq_char)*?) (\$) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
6999
|
0
|
|
|
|
|
0
|
elsif (/\G (\:) ((?:$qq_char)*?) (\:) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7000
|
|
|
|
|
|
|
elsif (/\G (\@) ((?:$qq_char)*?) (\@) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7001
|
0
|
|
|
|
|
0
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { return e_sub($sub_variable,@s,$1,$2,$3,$4); } |
7002
|
|
|
|
|
|
|
} |
7003
|
|
|
|
|
|
|
die __FILE__, ": Substitution replacement not terminated\n"; |
7004
|
|
|
|
|
|
|
} |
7005
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 $5 $6 |
7006
|
|
|
|
|
|
|
elsif (/\G (\') ((?:$qq_char)*?) (\') ((?:$qq_char)*?) (\') ([cegimosxpradlunbB]*) /oxgc) { |
7007
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7008
|
|
|
|
|
|
|
} |
7009
|
96
|
|
|
|
|
247
|
# $1 $2 $3 $4 $5 $6 |
7010
|
|
|
|
|
|
|
elsif (/\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7011
|
|
|
|
|
|
|
return e_sub($sub_variable,'{',$2,'}','{',$4,'}',$6); # s | | | --> s { } { } |
7012
|
|
|
|
|
|
|
} |
7013
|
2
|
|
|
|
|
23
|
# $1 $2 $3 $4 $5 $6 |
7014
|
|
|
|
|
|
|
elsif (/\G (\$) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7015
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7016
|
|
|
|
|
|
|
} |
7017
|
0
|
|
|
|
|
0
|
# $1 $2 $3 $4 $5 $6 |
7018
|
|
|
|
|
|
|
elsif (/\G (\S) ((?:$qq_char)*?) (\1) ((?:$qq_char)*?) (\1) ([cegimosxpradlunbB]*) /oxgc) { |
7019
|
|
|
|
|
|
|
return e_sub($sub_variable,$1,$2,$3,$3,$4,$5,$6); |
7020
|
191
|
|
|
|
|
970
|
} |
7021
|
|
|
|
|
|
|
} |
7022
|
|
|
|
|
|
|
die __FILE__, ": Substitution pattern not terminated\n"; |
7023
|
|
|
|
|
|
|
} |
7024
|
|
|
|
|
|
|
} |
7025
|
0
|
|
|
|
|
0
|
|
7026
|
1
|
|
|
|
|
7
|
# do |
7027
|
0
|
|
|
|
|
0
|
elsif (/\G \b do (?= (?>\s*) \{ ) /oxmsgc) { return 'do'; } |
7028
|
0
|
|
|
|
|
0
|
elsif (/\G \b do (?= (?>\s+) (?: q | qq | qx ) \b) /oxmsgc) { return 'Ehp15::do'; } |
7029
|
0
|
|
|
|
|
0
|
elsif (/\G \b do (?= (?>\s+) (?>\w+)) /oxmsgc) { return 'do'; } |
7030
|
|
|
|
|
|
|
elsif (/\G \b do (?= (?>\s*) \$ (?> \w+ (?: ::\w+)* ) \( ) /oxmsgc) { return 'do'; } |
7031
|
|
|
|
|
|
|
elsif (/\G \b do \b /oxmsgc) { return 'Ehp15::do'; } |
7032
|
2
|
|
|
|
|
11
|
|
7033
|
0
|
|
|
|
|
0
|
# require ignore module |
7034
|
0
|
|
|
|
|
0
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# require$1$2"; } |
7035
|
|
|
|
|
|
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x80-\xA0\xE0-\xFE#]) /oxmsgc) { return "# require$1\n$2"; } |
7036
|
|
|
|
|
|
|
elsif (/\G \b require ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# require$1"; } |
7037
|
0
|
|
|
|
|
0
|
|
7038
|
0
|
|
|
|
|
0
|
# require version number |
7039
|
0
|
|
|
|
|
0
|
elsif (/\G \b require (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7040
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7041
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7042
|
0
|
|
|
|
|
0
|
|
7043
|
|
|
|
|
|
|
# require bare package name |
7044
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s+) ((?>[A-Za-z_]\w* (?: :: [A-Za-z_]\w*)*)) (?>\s*) ; /oxmsgc) { return "require $1;"; } |
7045
|
18
|
|
|
|
|
120
|
|
7046
|
0
|
|
|
|
|
0
|
# require else |
7047
|
|
|
|
|
|
|
elsif (/\G \b require (?>\s*) ; /oxmsgc) { return 'Ehp15::require;'; } |
7048
|
|
|
|
|
|
|
elsif (/\G \b require \b /oxmsgc) { return 'Ehp15::require'; } |
7049
|
1
|
|
|
|
|
6
|
|
7050
|
70
|
|
|
|
|
618
|
# use strict; --> use strict; no strict qw(refs); |
7051
|
0
|
|
|
|
|
0
|
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "use$1 no strict qw(refs);$2"; } |
7052
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) strict .*? ;) ([ \t]* [^\x80-\xA0\xE0-\xFE#]) /oxmsgc) { return "use$1 no strict qw(refs);\n$2"; } |
7053
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) strict) \b /oxmsgc) { return "use$1; no strict qw(refs)"; } |
7054
|
|
|
|
|
|
|
|
7055
|
0
|
50
|
33
|
|
|
0
|
# use 5.12.0; --> use 5.12.0; no strict qw(refs); |
|
|
|
33
|
|
|
|
|
7056
|
3
|
|
|
|
|
40
|
elsif (/\G \b use (?>\s+) ((?>([1-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) { |
7057
|
|
|
|
|
|
|
if (($2 >= 6) or (($2 == 5) and ($3 ge '012'))) { |
7058
|
|
|
|
|
|
|
return "use $1; no strict qw(refs);"; |
7059
|
0
|
|
|
|
|
0
|
} |
7060
|
|
|
|
|
|
|
else { |
7061
|
|
|
|
|
|
|
return "use $1;"; |
7062
|
|
|
|
|
|
|
} |
7063
|
3
|
0
|
0
|
|
|
19
|
} |
|
|
|
0
|
|
|
|
|
7064
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>v([0-9][0-9_]*)(?:\.([0-9_]+))*)) (?>\s*) ; /oxmsgc) { |
7065
|
|
|
|
|
|
|
if (($2 >= 6) or (($2 == 5) and ($3 >= 12))) { |
7066
|
|
|
|
|
|
|
return "use $1; no strict qw(refs);"; |
7067
|
0
|
|
|
|
|
0
|
} |
7068
|
|
|
|
|
|
|
else { |
7069
|
|
|
|
|
|
|
return "use $1;"; |
7070
|
|
|
|
|
|
|
} |
7071
|
|
|
|
|
|
|
} |
7072
|
0
|
|
|
|
|
0
|
|
7073
|
2
|
|
|
|
|
17
|
# ignore use module |
7074
|
0
|
|
|
|
|
0
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# use$1$2"; } |
7075
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x80-\xA0\xE0-\xFE#]) /oxmsgc) { return "# use$1\n$2"; } |
7076
|
|
|
|
|
|
|
elsif (/\G \b use ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# use$1"; } |
7077
|
0
|
|
|
|
|
0
|
|
7078
|
0
|
|
|
|
|
0
|
# ignore no module |
7079
|
0
|
|
|
|
|
0
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [#\n]) /oxmsgc) { return "# no$1$2"; } |
7080
|
|
|
|
|
|
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules) .*? ;) ([ \t]* [^\x80-\xA0\xE0-\xFE#]) /oxmsgc) { return "# no$1\n$2"; } |
7081
|
|
|
|
|
|
|
elsif (/\G \b no ((?>\s+) (?:$ignore_modules)) \b /oxmsgc) { return "# no$1"; } |
7082
|
0
|
|
|
|
|
0
|
|
7083
|
0
|
|
|
|
|
0
|
# use without import |
7084
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7085
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7086
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "use $1;"; } |
7087
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7088
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7089
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\{) (?>\s*) \} (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7090
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\[) (?>\s*) \] (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7091
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\<) (?>\s*) \> (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7092
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) ([\x21-\x3F]) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7093
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\S) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_use_noimport($1); } |
7094
|
0
|
|
|
|
|
0
|
|
7095
|
|
|
|
|
|
|
# use with import no parameter |
7096
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ; /oxmsgc) { return e_use_noparam($1); } |
7097
|
0
|
|
|
|
|
0
|
|
7098
|
0
|
|
|
|
|
0
|
# use with import parameters |
7099
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\() [^\x80-\xA0\xE0-\xFE)]* \)) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7100
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\') [^\x80-\xA0\xE0-\xFE']* \') (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7101
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\") [^\x80-\xA0\xE0-\xFE"]* \") (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7102
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\() [^\x80-\xA0\xE0-\xFE)]* \)) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7103
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\{) (?:$q_char)*? \}) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7104
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\[) (?:$q_char)*? \]) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7105
|
0
|
|
|
|
|
0
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\<) [^\x80-\xA0\xE0-\xFE>]* \>) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7106
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) ([\x21-\x3F]) .*? \3) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7107
|
|
|
|
|
|
|
elsif (/\G \b use (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\S) (?:$q_char)*? \3) (?>\s*) ; /oxmsgc) { return e_use($1,$2); } |
7108
|
0
|
|
|
|
|
0
|
|
7109
|
0
|
|
|
|
|
0
|
# no without unimport |
7110
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>0[0-7_]*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7111
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[1-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7112
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>v[0-9][0-9_]*(?:\.[0-9_]+)*)) (?>\s*) ; /oxmsgc) { return "no $1;"; } |
7113
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7114
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\() (?>\s*) \) (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7115
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\{) (?>\s*) \} (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7116
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\[) (?>\s*) \] (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7117
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\<) (?>\s*) \> (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7118
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) ([\x21-\x3F]) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7119
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) qw (?>\s*) (\S) (?>\s*) \2 (?>\s*) ; /oxmsgc) { return e_no_nounimport($1); } |
7120
|
0
|
|
|
|
|
0
|
|
7121
|
|
|
|
|
|
|
# no with unimport no parameter |
7122
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ; /oxmsgc) { return e_no_noparam($1); } |
7123
|
0
|
|
|
|
|
0
|
|
7124
|
0
|
|
|
|
|
0
|
# no with unimport parameters |
7125
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\() [^\x80-\xA0\xE0-\xFE)]* \)) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7126
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\') [^\x80-\xA0\xE0-\xFE']* \') (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7127
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s*) ( (\") [^\x80-\xA0\xE0-\xFE"]* \") (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7128
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\() [^\x80-\xA0\xE0-\xFE)]* \)) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7129
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\{) (?:$q_char)*? \}) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7130
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\[) (?:$q_char)*? \]) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7131
|
0
|
|
|
|
|
0
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\<) [^\x80-\xA0\xE0-\xFE>]* \>) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7132
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) ([\x21-\x3F]) .*? \3) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7133
|
|
|
|
|
|
|
elsif (/\G \b no (?>\s+) ((?>[A-Z]\w*(?: ::\w+)*)) (?>\s+) ((?: q | qq | qw ) (?>\s*) (\S) (?:$q_char)*? \3) (?>\s*) ; /oxmsgc) { return e_no($1,$2); } |
7134
|
0
|
|
|
|
|
0
|
|
7135
|
|
|
|
|
|
|
# use else |
7136
|
|
|
|
|
|
|
elsif (/\G \b use \b /oxmsgc) { return "use"; } |
7137
|
0
|
|
|
|
|
0
|
|
7138
|
|
|
|
|
|
|
# use else |
7139
|
|
|
|
|
|
|
elsif (/\G \b no \b /oxmsgc) { return "no"; } |
7140
|
|
|
|
|
|
|
|
7141
|
2
|
|
|
|
|
10
|
# '' |
7142
|
3177
|
|
|
|
|
7625
|
elsif (/\G (?
|
7143
|
3177
|
100
|
|
|
|
9087
|
my $q_string = ''; |
|
15691
|
100
|
|
|
|
57236
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7144
|
8
|
|
|
|
|
29
|
while (not /\G \z/oxgc) { |
7145
|
48
|
|
|
|
|
99
|
if (/\G (\\\\) /oxgc) { $q_string .= $1; } |
7146
|
3177
|
|
|
|
|
7705
|
elsif (/\G (\\\') /oxgc) { $q_string .= $1; } |
7147
|
|
|
|
|
|
|
elsif (/\G \' /oxgc) { return e_q('', "'","'",$q_string); } |
7148
|
12458
|
|
|
|
|
28450
|
elsif (/\G ($q_char) /oxgc) { $q_string .= $1; } |
7149
|
|
|
|
|
|
|
} |
7150
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7151
|
|
|
|
|
|
|
} |
7152
|
|
|
|
|
|
|
|
7153
|
0
|
|
|
|
|
0
|
# "" |
7154
|
3404
|
|
|
|
|
8815
|
elsif (/\G (\") /oxgc) { |
7155
|
3404
|
100
|
|
|
|
9397
|
my $qq_string = ''; |
|
70201
|
100
|
|
|
|
217664
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7156
|
109
|
|
|
|
|
228
|
while (not /\G \z/oxgc) { |
7157
|
14
|
|
|
|
|
32
|
if (/\G (\\\\) /oxgc) { $qq_string .= $1; } |
7158
|
3404
|
|
|
|
|
8577
|
elsif (/\G (\\\") /oxgc) { $qq_string .= $1; } |
7159
|
|
|
|
|
|
|
elsif (/\G \" /oxgc) { return e_qq('', '"','"',$qq_string); } |
7160
|
66674
|
|
|
|
|
150130
|
elsif (/\G ($q_char) /oxgc) { $qq_string .= $1; } |
7161
|
|
|
|
|
|
|
} |
7162
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7163
|
|
|
|
|
|
|
} |
7164
|
|
|
|
|
|
|
|
7165
|
0
|
|
|
|
|
0
|
# `` |
7166
|
37
|
|
|
|
|
116
|
elsif (/\G (\`) /oxgc) { |
7167
|
37
|
50
|
|
|
|
152
|
my $qx_string = ''; |
|
313
|
50
|
|
|
|
2108
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7168
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7169
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $qx_string .= $1; } |
7170
|
37
|
|
|
|
|
180
|
elsif (/\G (\\\`) /oxgc) { $qx_string .= $1; } |
7171
|
|
|
|
|
|
|
elsif (/\G \` /oxgc) { return e_qq('', '`','`',$qx_string); } |
7172
|
276
|
|
|
|
|
849
|
elsif (/\G ($q_char) /oxgc) { $qx_string .= $1; } |
7173
|
|
|
|
|
|
|
} |
7174
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7175
|
|
|
|
|
|
|
} |
7176
|
|
|
|
|
|
|
|
7177
|
0
|
|
|
|
|
0
|
# // --- not divide operator (num / num), not defined-or |
7178
|
1231
|
|
|
|
|
3287
|
elsif (($slash eq 'm//') and /\G (\/) /oxgc) { |
7179
|
1231
|
100
|
|
|
|
4113
|
my $regexp = ''; |
|
12510
|
50
|
|
|
|
44668
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7180
|
11
|
|
|
|
|
36
|
while (not /\G \z/oxgc) { |
7181
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
7182
|
1231
|
|
|
|
|
3604
|
elsif (/\G (\\\/) /oxgc) { $regexp .= $1; } |
7183
|
|
|
|
|
|
|
elsif (/\G \/ ([cgimosxpadlunbB]*) /oxgc) { return e_qr('', '/','/',$regexp,$1); } |
7184
|
11268
|
|
|
|
|
24382
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
7185
|
|
|
|
|
|
|
} |
7186
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7187
|
|
|
|
|
|
|
} |
7188
|
|
|
|
|
|
|
|
7189
|
0
|
|
|
|
|
0
|
# ?? --- not conditional operator (condition ? then : else) |
7190
|
92
|
|
|
|
|
253
|
elsif (($slash eq 'm//') and /\G (\?) /oxgc) { |
7191
|
92
|
50
|
|
|
|
217
|
my $regexp = ''; |
|
266
|
50
|
|
|
|
985
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7192
|
0
|
|
|
|
|
0
|
while (not /\G \z/oxgc) { |
7193
|
0
|
|
|
|
|
0
|
if (/\G (\\\\) /oxgc) { $regexp .= $1; } |
7194
|
92
|
|
|
|
|
216
|
elsif (/\G (\\\?) /oxgc) { $regexp .= $1; } |
7195
|
|
|
|
|
|
|
elsif (/\G \? ([cgimosxpadlunbB]*) /oxgc) { return e_qr('m','?','?',$regexp,$1); } |
7196
|
174
|
|
|
|
|
423
|
elsif (/\G ($q_char) /oxgc) { $regexp .= $1; } |
7197
|
|
|
|
|
|
|
} |
7198
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7199
|
|
|
|
|
|
|
} |
7200
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7201
|
|
|
|
|
|
|
# <<>> (a safer ARGV) |
7202
|
|
|
|
|
|
|
elsif (/\G ( <<>> ) /oxgc) { $slash = 'm//'; return $1; } |
7203
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7204
|
|
|
|
|
|
|
# << (bit shift) --- not here document |
7205
|
|
|
|
|
|
|
elsif (/\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { $slash = 'm//'; return $1; } |
7206
|
|
|
|
|
|
|
|
7207
|
0
|
|
|
|
|
0
|
# <<~'HEREDOC' |
7208
|
6
|
|
|
|
|
14
|
elsif (/\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) { |
7209
|
6
|
|
|
|
|
12
|
$slash = 'm//'; |
7210
|
|
|
|
|
|
|
my $here_quote = $1; |
7211
|
|
|
|
|
|
|
my $delimiter = $2; |
7212
|
6
|
50
|
|
|
|
9
|
|
7213
|
6
|
|
|
|
|
12
|
# get here document |
7214
|
6
|
|
|
|
|
31
|
if ($here_script eq '') { |
7215
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7216
|
6
|
50
|
|
|
|
33
|
$here_script =~ s/.*?\n//oxm; |
7217
|
6
|
|
|
|
|
50
|
} |
7218
|
6
|
|
|
|
|
13
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7219
|
6
|
|
|
|
|
8
|
my $heredoc = $1; |
7220
|
6
|
|
|
|
|
47
|
my $indent = $2; |
7221
|
6
|
|
|
|
|
17
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7222
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
7223
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7224
|
6
|
|
|
|
|
23
|
} |
7225
|
|
|
|
|
|
|
else { |
7226
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7227
|
|
|
|
|
|
|
} |
7228
|
|
|
|
|
|
|
return qq{<<'$delimiter'}; |
7229
|
|
|
|
|
|
|
} |
7230
|
|
|
|
|
|
|
|
7231
|
|
|
|
|
|
|
# <<~\HEREDOC |
7232
|
|
|
|
|
|
|
|
7233
|
|
|
|
|
|
|
# P.66 2.6.6. "Here" Documents |
7234
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7235
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7236
|
|
|
|
|
|
|
|
7237
|
|
|
|
|
|
|
# P.73 "Here" Documents |
7238
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7239
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7240
|
6
|
|
|
|
|
33
|
|
7241
|
3
|
|
|
|
|
8
|
elsif (/\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) { |
7242
|
3
|
|
|
|
|
7
|
$slash = 'm//'; |
7243
|
|
|
|
|
|
|
my $here_quote = $1; |
7244
|
|
|
|
|
|
|
my $delimiter = $2; |
7245
|
3
|
50
|
|
|
|
7
|
|
7246
|
3
|
|
|
|
|
18
|
# get here document |
7247
|
3
|
|
|
|
|
15
|
if ($here_script eq '') { |
7248
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7249
|
3
|
50
|
|
|
|
15
|
$here_script =~ s/.*?\n//oxm; |
7250
|
3
|
|
|
|
|
34
|
} |
7251
|
3
|
|
|
|
|
8
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7252
|
3
|
|
|
|
|
5
|
my $heredoc = $1; |
7253
|
3
|
|
|
|
|
36
|
my $indent = $2; |
7254
|
3
|
|
|
|
|
9
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7255
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
7256
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7257
|
3
|
|
|
|
|
7
|
} |
7258
|
|
|
|
|
|
|
else { |
7259
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7260
|
|
|
|
|
|
|
} |
7261
|
|
|
|
|
|
|
return qq{<<\\$delimiter}; |
7262
|
|
|
|
|
|
|
} |
7263
|
|
|
|
|
|
|
|
7264
|
3
|
|
|
|
|
13
|
# <<~"HEREDOC" |
7265
|
6
|
|
|
|
|
15
|
elsif (/\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) { |
7266
|
6
|
|
|
|
|
28
|
$slash = 'm//'; |
7267
|
|
|
|
|
|
|
my $here_quote = $1; |
7268
|
|
|
|
|
|
|
my $delimiter = $2; |
7269
|
6
|
50
|
|
|
|
13
|
|
7270
|
6
|
|
|
|
|
14
|
# get here document |
7271
|
6
|
|
|
|
|
28
|
if ($here_script eq '') { |
7272
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7273
|
6
|
50
|
|
|
|
32
|
$here_script =~ s/.*?\n//oxm; |
7274
|
6
|
|
|
|
|
119
|
} |
7275
|
6
|
|
|
|
|
16
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7276
|
6
|
|
|
|
|
8
|
my $heredoc = $1; |
7277
|
6
|
|
|
|
|
50
|
my $indent = $2; |
7278
|
6
|
|
|
|
|
18
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7279
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7280
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7281
|
6
|
|
|
|
|
13
|
} |
7282
|
|
|
|
|
|
|
else { |
7283
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7284
|
|
|
|
|
|
|
} |
7285
|
|
|
|
|
|
|
return qq{<<"$delimiter"}; |
7286
|
|
|
|
|
|
|
} |
7287
|
|
|
|
|
|
|
|
7288
|
6
|
|
|
|
|
48
|
# <<~HEREDOC |
7289
|
3
|
|
|
|
|
7
|
elsif (/\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) { |
7290
|
3
|
|
|
|
|
8
|
$slash = 'm//'; |
7291
|
|
|
|
|
|
|
my $here_quote = $1; |
7292
|
|
|
|
|
|
|
my $delimiter = $2; |
7293
|
3
|
50
|
|
|
|
7
|
|
7294
|
3
|
|
|
|
|
7
|
# get here document |
7295
|
3
|
|
|
|
|
16
|
if ($here_script eq '') { |
7296
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7297
|
3
|
50
|
|
|
|
17
|
$here_script =~ s/.*?\n//oxm; |
7298
|
3
|
|
|
|
|
40
|
} |
7299
|
3
|
|
|
|
|
7
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7300
|
3
|
|
|
|
|
7
|
my $heredoc = $1; |
7301
|
3
|
|
|
|
|
37
|
my $indent = $2; |
7302
|
3
|
|
|
|
|
12
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7303
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7304
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7305
|
3
|
|
|
|
|
9
|
} |
7306
|
|
|
|
|
|
|
else { |
7307
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7308
|
|
|
|
|
|
|
} |
7309
|
|
|
|
|
|
|
return qq{<<$delimiter}; |
7310
|
|
|
|
|
|
|
} |
7311
|
|
|
|
|
|
|
|
7312
|
3
|
|
|
|
|
12
|
# <<~`HEREDOC` |
7313
|
6
|
|
|
|
|
13
|
elsif (/\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) { |
7314
|
6
|
|
|
|
|
13
|
$slash = 'm//'; |
7315
|
|
|
|
|
|
|
my $here_quote = $1; |
7316
|
|
|
|
|
|
|
my $delimiter = $2; |
7317
|
6
|
50
|
|
|
|
7
|
|
7318
|
6
|
|
|
|
|
14
|
# get here document |
7319
|
6
|
|
|
|
|
22
|
if ($here_script eq '') { |
7320
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7321
|
6
|
50
|
|
|
|
29
|
$here_script =~ s/.*?\n//oxm; |
7322
|
6
|
|
|
|
|
61
|
} |
7323
|
6
|
|
|
|
|
14
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
7324
|
6
|
|
|
|
|
13
|
my $heredoc = $1; |
7325
|
6
|
|
|
|
|
48
|
my $indent = $2; |
7326
|
6
|
|
|
|
|
17
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
7327
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
7328
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
7329
|
6
|
|
|
|
|
13
|
} |
7330
|
|
|
|
|
|
|
else { |
7331
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7332
|
|
|
|
|
|
|
} |
7333
|
|
|
|
|
|
|
return qq{<<`$delimiter`}; |
7334
|
|
|
|
|
|
|
} |
7335
|
|
|
|
|
|
|
|
7336
|
6
|
|
|
|
|
24
|
# <<'HEREDOC' |
7337
|
86
|
|
|
|
|
267
|
elsif (/\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) { |
7338
|
86
|
|
|
|
|
201
|
$slash = 'm//'; |
7339
|
|
|
|
|
|
|
my $here_quote = $1; |
7340
|
|
|
|
|
|
|
my $delimiter = $2; |
7341
|
86
|
100
|
|
|
|
153
|
|
7342
|
86
|
|
|
|
|
181
|
# get here document |
7343
|
83
|
|
|
|
|
459
|
if ($here_script eq '') { |
7344
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7345
|
83
|
50
|
|
|
|
463
|
$here_script =~ s/.*?\n//oxm; |
7346
|
86
|
|
|
|
|
706
|
} |
7347
|
86
|
|
|
|
|
289
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7348
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
7349
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
7350
|
86
|
|
|
|
|
149
|
} |
7351
|
|
|
|
|
|
|
else { |
7352
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7353
|
|
|
|
|
|
|
} |
7354
|
|
|
|
|
|
|
return $here_quote; |
7355
|
|
|
|
|
|
|
} |
7356
|
|
|
|
|
|
|
|
7357
|
|
|
|
|
|
|
# <<\HEREDOC |
7358
|
|
|
|
|
|
|
|
7359
|
|
|
|
|
|
|
# P.66 2.6.6. "Here" Documents |
7360
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7361
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7362
|
|
|
|
|
|
|
|
7363
|
|
|
|
|
|
|
# P.73 "Here" Documents |
7364
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7365
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7366
|
86
|
|
|
|
|
326
|
|
7367
|
2
|
|
|
|
|
5
|
elsif (/\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) { |
7368
|
2
|
|
|
|
|
6
|
$slash = 'm//'; |
7369
|
|
|
|
|
|
|
my $here_quote = $1; |
7370
|
|
|
|
|
|
|
my $delimiter = $2; |
7371
|
2
|
100
|
|
|
|
3
|
|
7372
|
2
|
|
|
|
|
6
|
# get here document |
7373
|
1
|
|
|
|
|
8
|
if ($here_script eq '') { |
7374
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7375
|
1
|
50
|
|
|
|
6
|
$here_script =~ s/.*?\n//oxm; |
7376
|
2
|
|
|
|
|
29
|
} |
7377
|
2
|
|
|
|
|
7
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7378
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
7379
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
7380
|
2
|
|
|
|
|
4
|
} |
7381
|
|
|
|
|
|
|
else { |
7382
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7383
|
|
|
|
|
|
|
} |
7384
|
|
|
|
|
|
|
return $here_quote; |
7385
|
|
|
|
|
|
|
} |
7386
|
|
|
|
|
|
|
|
7387
|
2
|
|
|
|
|
8
|
# <<"HEREDOC" |
7388
|
39
|
|
|
|
|
100
|
elsif (/\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) { |
7389
|
39
|
|
|
|
|
103
|
$slash = 'm//'; |
7390
|
|
|
|
|
|
|
my $here_quote = $1; |
7391
|
|
|
|
|
|
|
my $delimiter = $2; |
7392
|
39
|
100
|
|
|
|
86
|
|
7393
|
39
|
|
|
|
|
111
|
# get here document |
7394
|
38
|
|
|
|
|
333
|
if ($here_script eq '') { |
7395
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7396
|
38
|
50
|
|
|
|
241
|
$here_script =~ s/.*?\n//oxm; |
7397
|
39
|
|
|
|
|
582
|
} |
7398
|
39
|
|
|
|
|
147
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7399
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7400
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
7401
|
39
|
|
|
|
|
99
|
} |
7402
|
|
|
|
|
|
|
else { |
7403
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7404
|
|
|
|
|
|
|
} |
7405
|
|
|
|
|
|
|
return $here_quote; |
7406
|
|
|
|
|
|
|
} |
7407
|
|
|
|
|
|
|
|
7408
|
39
|
|
|
|
|
179
|
# <
|
7409
|
54
|
|
|
|
|
137
|
elsif (/\G ( << ([a-zA-Z_0-9]+) ) /oxgc) { |
7410
|
54
|
|
|
|
|
123
|
$slash = 'm//'; |
7411
|
|
|
|
|
|
|
my $here_quote = $1; |
7412
|
|
|
|
|
|
|
my $delimiter = $2; |
7413
|
54
|
100
|
|
|
|
108
|
|
7414
|
54
|
|
|
|
|
161
|
# get here document |
7415
|
51
|
|
|
|
|
320
|
if ($here_script eq '') { |
7416
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7417
|
51
|
50
|
|
|
|
387
|
$here_script =~ s/.*?\n//oxm; |
7418
|
54
|
|
|
|
|
745
|
} |
7419
|
54
|
|
|
|
|
191
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7420
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7421
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
7422
|
54
|
|
|
|
|
123
|
} |
7423
|
|
|
|
|
|
|
else { |
7424
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7425
|
|
|
|
|
|
|
} |
7426
|
|
|
|
|
|
|
return $here_quote; |
7427
|
|
|
|
|
|
|
} |
7428
|
|
|
|
|
|
|
|
7429
|
54
|
|
|
|
|
232
|
# <<`HEREDOC` |
7430
|
0
|
|
|
|
|
0
|
elsif (/\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) { |
7431
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
7432
|
|
|
|
|
|
|
my $here_quote = $1; |
7433
|
|
|
|
|
|
|
my $delimiter = $2; |
7434
|
0
|
0
|
|
|
|
0
|
|
7435
|
0
|
|
|
|
|
0
|
# get here document |
7436
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
7437
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
7438
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
7439
|
0
|
|
|
|
|
0
|
} |
7440
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
7441
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
7442
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
7443
|
0
|
|
|
|
|
0
|
} |
7444
|
|
|
|
|
|
|
else { |
7445
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
7446
|
|
|
|
|
|
|
} |
7447
|
|
|
|
|
|
|
return $here_quote; |
7448
|
|
|
|
|
|
|
} |
7449
|
|
|
|
|
|
|
|
7450
|
0
|
|
|
|
|
0
|
# <<= <=> <= < operator |
7451
|
|
|
|
|
|
|
elsif (/\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { |
7452
|
|
|
|
|
|
|
return $1; |
7453
|
|
|
|
|
|
|
} |
7454
|
|
|
|
|
|
|
|
7455
|
13
|
|
|
|
|
88
|
# |
7456
|
|
|
|
|
|
|
elsif (/\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { |
7457
|
|
|
|
|
|
|
return $1; |
7458
|
|
|
|
|
|
|
} |
7459
|
|
|
|
|
|
|
|
7460
|
|
|
|
|
|
|
# --- glob |
7461
|
|
|
|
|
|
|
|
7462
|
|
|
|
|
|
|
# avoid "Error: Runtime exception" of perl version 5.005_03 |
7463
|
0
|
|
|
|
|
0
|
|
7464
|
|
|
|
|
|
|
elsif (/\G < ((?:[^\x80-\xA0\xE0-\xFE>\0\a\e\f\n\r\t]|[\x80-\xA0\xE0-\xFE][\x00-\xFF])+?) > /oxgc) { |
7465
|
|
|
|
|
|
|
return 'Ehp15::glob("' . $1 . '")'; |
7466
|
|
|
|
|
|
|
} |
7467
|
0
|
|
|
|
|
0
|
|
7468
|
|
|
|
|
|
|
# __DATA__ |
7469
|
|
|
|
|
|
|
elsif (/\G ^ ( __DATA__ \n .*) \z /oxmsgc) { return $1; } |
7470
|
0
|
|
|
|
|
0
|
|
7471
|
|
|
|
|
|
|
# __END__ |
7472
|
|
|
|
|
|
|
elsif (/\G ^ ( __END__ \n .*) \z /oxmsgc) { return $1; } |
7473
|
|
|
|
|
|
|
|
7474
|
|
|
|
|
|
|
# \cD Control-D |
7475
|
|
|
|
|
|
|
|
7476
|
|
|
|
|
|
|
# P.68 2.6.8. Other Literal Tokens |
7477
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7478
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
7479
|
|
|
|
|
|
|
|
7480
|
|
|
|
|
|
|
# P.76 Other Literal Tokens |
7481
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
7482
|
384
|
|
|
|
|
3155
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7483
|
|
|
|
|
|
|
|
7484
|
|
|
|
|
|
|
elsif (/\G ( \cD .*) \z /oxmsgc) { return $1; } |
7485
|
0
|
|
|
|
|
0
|
|
7486
|
|
|
|
|
|
|
# \cZ Control-Z |
7487
|
|
|
|
|
|
|
elsif (/\G ( \cZ .*) \z /oxmsgc) { return $1; } |
7488
|
|
|
|
|
|
|
|
7489
|
|
|
|
|
|
|
# any operator before div |
7490
|
|
|
|
|
|
|
elsif (/\G ( |
7491
|
|
|
|
|
|
|
-- | \+\+ | |
7492
|
0
|
|
|
|
|
0
|
[\)\}\]] |
|
14161
|
|
|
|
|
31608
|
|
7493
|
|
|
|
|
|
|
|
7494
|
|
|
|
|
|
|
) /oxgc) { $slash = 'div'; return $1; } |
7495
|
|
|
|
|
|
|
|
7496
|
|
|
|
|
|
|
# yada-yada or triple-dot operator |
7497
|
|
|
|
|
|
|
elsif (/\G ( |
7498
|
14161
|
|
|
|
|
86729
|
\.\.\. |
|
7
|
|
|
|
|
21
|
|
7499
|
|
|
|
|
|
|
|
7500
|
|
|
|
|
|
|
) /oxgc) { $slash = 'm//'; return q{die('Unimplemented')}; } |
7501
|
|
|
|
|
|
|
|
7502
|
|
|
|
|
|
|
# any operator before m// |
7503
|
|
|
|
|
|
|
|
7504
|
|
|
|
|
|
|
# //, //= (defined-or) |
7505
|
|
|
|
|
|
|
|
7506
|
|
|
|
|
|
|
# P.164 Logical Operators |
7507
|
|
|
|
|
|
|
# in Chapter 10: More Control Structures |
7508
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
7509
|
|
|
|
|
|
|
|
7510
|
|
|
|
|
|
|
# P.119 C-Style Logical (Short-Circuit) Operators |
7511
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
7512
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7513
|
|
|
|
|
|
|
|
7514
|
|
|
|
|
|
|
# (and so on) |
7515
|
|
|
|
|
|
|
|
7516
|
|
|
|
|
|
|
# ~~ |
7517
|
|
|
|
|
|
|
|
7518
|
|
|
|
|
|
|
# P.221 The Smart Match Operator |
7519
|
|
|
|
|
|
|
# in Chapter 15: Smart Matching and given-when |
7520
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
7521
|
|
|
|
|
|
|
|
7522
|
|
|
|
|
|
|
# P.112 Smartmatch Operator |
7523
|
|
|
|
|
|
|
# in Chapter 3: Unary and Binary Operators |
7524
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
7525
|
|
|
|
|
|
|
|
7526
|
|
|
|
|
|
|
# (and so on) |
7527
|
|
|
|
|
|
|
|
7528
|
|
|
|
|
|
|
elsif (/\G ((?> |
7529
|
|
|
|
|
|
|
|
7530
|
|
|
|
|
|
|
!~~ | !~ | != | ! | |
7531
|
|
|
|
|
|
|
%= | % | |
7532
|
|
|
|
|
|
|
&&= | && | &= | &\.= | &\. | & | |
7533
|
|
|
|
|
|
|
-= | -> | - | |
7534
|
|
|
|
|
|
|
:(?>\s*)= | |
7535
|
|
|
|
|
|
|
: | |
7536
|
|
|
|
|
|
|
<<>> | |
7537
|
|
|
|
|
|
|
<<= | <=> | <= | < | |
7538
|
|
|
|
|
|
|
== | => | =~ | = | |
7539
|
|
|
|
|
|
|
>>= | >> | >= | > | |
7540
|
|
|
|
|
|
|
\*\*= | \*\* | \*= | \* | |
7541
|
|
|
|
|
|
|
\+= | \+ | |
7542
|
|
|
|
|
|
|
\.\. | \.= | \. | |
7543
|
|
|
|
|
|
|
\/\/= | \/\/ | |
7544
|
|
|
|
|
|
|
\/= | \/ | |
7545
|
|
|
|
|
|
|
\? | |
7546
|
|
|
|
|
|
|
\\ | |
7547
|
|
|
|
|
|
|
\^= | \^\.= | \^\. | \^ | |
7548
|
|
|
|
|
|
|
\b x= | |
7549
|
|
|
|
|
|
|
\|\|= | \|\| | \|= | \|\.= | \|\. | \| | |
7550
|
|
|
|
|
|
|
~~ | ~\. | ~ | |
7551
|
|
|
|
|
|
|
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | |
7552
|
|
|
|
|
|
|
\b(?: print )\b | |
7553
|
|
|
|
|
|
|
|
7554
|
7
|
|
|
|
|
32
|
[,;\(\{\[] |
|
23792
|
|
|
|
|
54226
|
|
7555
|
|
|
|
|
|
|
|
7556
|
|
|
|
|
|
|
)) /oxgc) { $slash = 'm//'; return $1; } |
7557
|
23792
|
|
|
|
|
118018
|
|
|
37029
|
|
|
|
|
78694
|
|
7558
|
|
|
|
|
|
|
# other any character |
7559
|
|
|
|
|
|
|
elsif (/\G ($q_char) /oxgc) { $slash = 'div'; return $1; } |
7560
|
|
|
|
|
|
|
|
7561
|
37029
|
|
|
|
|
194923
|
# system error |
7562
|
|
|
|
|
|
|
else { |
7563
|
|
|
|
|
|
|
die __FILE__, ": Oops, this shouldn't happen!\n"; |
7564
|
|
|
|
|
|
|
} |
7565
|
|
|
|
|
|
|
} |
7566
|
|
|
|
|
|
|
|
7567
|
0
|
|
|
3097
|
0
|
0
|
# escape HP-15 string |
7568
|
3097
|
|
|
|
|
7565
|
sub e_string { |
7569
|
|
|
|
|
|
|
my($string) = @_; |
7570
|
3097
|
|
|
|
|
4613
|
my $e_string = ''; |
7571
|
|
|
|
|
|
|
|
7572
|
|
|
|
|
|
|
local $slash = 'm//'; |
7573
|
|
|
|
|
|
|
|
7574
|
|
|
|
|
|
|
# P.1024 Appendix W.10 Multibyte Processing |
7575
|
|
|
|
|
|
|
# of ISBN 1-56592-224-7 CJKV Information Processing |
7576
|
3097
|
|
|
|
|
4684
|
# (and so on) |
7577
|
|
|
|
|
|
|
|
7578
|
|
|
|
|
|
|
my @char = $string =~ / \G (?>[^\x80-\xA0\xE0-\xFE\\]|\\$q_char|$q_char) /oxmsg; |
7579
|
3097
|
100
|
66
|
|
|
29509
|
|
7580
|
3097
|
50
|
|
|
|
14610
|
# without { ... } |
7581
|
3018
|
|
|
|
|
7238
|
if (not (grep(/\A \{ \z/xms, @char) and grep(/\A \} \z/xms, @char))) { |
7582
|
|
|
|
|
|
|
if ($string !~ /<
|
7583
|
|
|
|
|
|
|
return $string; |
7584
|
|
|
|
|
|
|
} |
7585
|
|
|
|
|
|
|
} |
7586
|
3018
|
|
|
|
|
8081
|
|
7587
|
79
|
50
|
|
|
|
233
|
E_STRING_LOOP: |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
7588
|
|
|
|
|
|
|
while ($string !~ /\G \z/oxgc) { |
7589
|
|
|
|
|
|
|
if (0) { |
7590
|
|
|
|
|
|
|
} |
7591
|
606
|
|
|
|
|
88393
|
|
7592
|
0
|
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> @{[Ehp15::PREMATCH()]} |
7593
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH \b | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) /oxmsgc) { |
7594
|
|
|
|
|
|
|
$e_string .= q{Ehp15::PREMATCH()}; |
7595
|
|
|
|
|
|
|
$slash = 'div'; |
7596
|
|
|
|
|
|
|
} |
7597
|
|
|
|
|
|
|
|
7598
|
0
|
|
|
|
|
0
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> @{[Ehp15::MATCH()]} |
7599
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$& | \$\{&\} | \$ (?>\s*) MATCH \b | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) /oxmsgc) { |
7600
|
|
|
|
|
|
|
$e_string .= q{Ehp15::MATCH()}; |
7601
|
|
|
|
|
|
|
$slash = 'div'; |
7602
|
|
|
|
|
|
|
} |
7603
|
|
|
|
|
|
|
|
7604
|
0
|
|
|
|
|
0
|
# $', ${'} --> $', ${'} |
7605
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$' | \$\{'\} ) /oxmsgc) { |
7606
|
|
|
|
|
|
|
$e_string .= $1; |
7607
|
|
|
|
|
|
|
$slash = 'div'; |
7608
|
|
|
|
|
|
|
} |
7609
|
|
|
|
|
|
|
|
7610
|
0
|
|
|
|
|
0
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> @{[Ehp15::POSTMATCH()]} |
7611
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$ (?>\s*) POSTMATCH \b | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) /oxmsgc) { |
7612
|
|
|
|
|
|
|
$e_string .= q{Ehp15::POSTMATCH()}; |
7613
|
|
|
|
|
|
|
$slash = 'div'; |
7614
|
|
|
|
|
|
|
} |
7615
|
|
|
|
|
|
|
|
7616
|
0
|
|
|
|
|
0
|
# bareword |
7617
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \{ (?>\s*) (?: tr | index | rindex | reverse ) (?>\s*) \} ) /oxmsgc) { |
7618
|
|
|
|
|
|
|
$e_string .= $1; |
7619
|
|
|
|
|
|
|
$slash = 'div'; |
7620
|
|
|
|
|
|
|
} |
7621
|
|
|
|
|
|
|
|
7622
|
0
|
|
|
|
|
0
|
# $0 --> $0 |
7623
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$ 0 ) /oxmsgc) { |
7624
|
|
|
|
|
|
|
$e_string .= $1; |
7625
|
|
|
|
|
|
|
$slash = 'div'; |
7626
|
0
|
|
|
|
|
0
|
} |
7627
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$ \{ (?>\s*) 0 (?>\s*) \} ) /oxmsgc) { |
7628
|
|
|
|
|
|
|
$e_string .= $1; |
7629
|
|
|
|
|
|
|
$slash = 'div'; |
7630
|
|
|
|
|
|
|
} |
7631
|
|
|
|
|
|
|
|
7632
|
0
|
|
|
|
|
0
|
# $$ --> $$ |
7633
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$ \$ ) (?![\w\{]) /oxmsgc) { |
7634
|
|
|
|
|
|
|
$e_string .= $1; |
7635
|
|
|
|
|
|
|
$slash = 'div'; |
7636
|
|
|
|
|
|
|
} |
7637
|
|
|
|
|
|
|
|
7638
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
7639
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
7640
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ ((?>[1-9][0-9]*)) /oxmsgc) { |
7641
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7642
|
|
|
|
|
|
|
$slash = 'div'; |
7643
|
0
|
|
|
|
|
0
|
} |
7644
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} /oxmsgc) { |
7645
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7646
|
|
|
|
|
|
|
$slash = 'div'; |
7647
|
|
|
|
|
|
|
} |
7648
|
|
|
|
|
|
|
|
7649
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
7650
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ .+? \] ) /oxmsgc) { |
7651
|
|
|
|
|
|
|
$e_string .= e_capture($1.'->'.$2); |
7652
|
|
|
|
|
|
|
$slash = 'div'; |
7653
|
|
|
|
|
|
|
} |
7654
|
|
|
|
|
|
|
|
7655
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
7656
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ .+? \} ) /oxmsgc) { |
7657
|
|
|
|
|
|
|
$e_string .= e_capture($1.'->'.$2); |
7658
|
|
|
|
|
|
|
$slash = 'div'; |
7659
|
|
|
|
|
|
|
} |
7660
|
|
|
|
|
|
|
|
7661
|
0
|
|
|
|
|
0
|
# $$foo |
7662
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) /oxmsgc) { |
7663
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7664
|
|
|
|
|
|
|
$slash = 'div'; |
7665
|
|
|
|
|
|
|
} |
7666
|
|
|
|
|
|
|
|
7667
|
0
|
|
|
|
|
0
|
# ${ foo } |
7668
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} /oxmsgc) { |
7669
|
|
|
|
|
|
|
$e_string .= '${' . $1 . '}'; |
7670
|
|
|
|
|
|
|
$slash = 'div'; |
7671
|
|
|
|
|
|
|
} |
7672
|
|
|
|
|
|
|
|
7673
|
0
|
|
|
|
|
0
|
# ${ ... } |
7674
|
3
|
|
|
|
|
12
|
elsif ($string =~ /\G \$ (?>\s*) \{ (?>\s*) ( $qq_brace ) (?>\s*) \} /oxmsgc) { |
7675
|
|
|
|
|
|
|
$e_string .= e_capture($1); |
7676
|
|
|
|
|
|
|
$slash = 'div'; |
7677
|
|
|
|
|
|
|
} |
7678
|
|
|
|
|
|
|
|
7679
|
|
|
|
|
|
|
# variable or function |
7680
|
3
|
|
|
|
|
14
|
# $ @ % & * $ # |
7681
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( (?: [\$\@\%\&\*] | \$\# | -> | \b sub \b) (?>\s*) (?: split | chop | index | rindex | lc | uc | fc | chr | ord | reverse | getc | tr | y | q | qq | qx | qw | m | s | qr | glob | lstat | opendir | stat | unlink | chdir ) ) \b /oxmsgc) { |
7682
|
|
|
|
|
|
|
$e_string .= $1; |
7683
|
|
|
|
|
|
|
$slash = 'div'; |
7684
|
|
|
|
|
|
|
} |
7685
|
|
|
|
|
|
|
# $ $ $ $ $ $ $ $ $ $ $ $ $ $ |
7686
|
0
|
|
|
|
|
0
|
# $ @ # \ ' " / ? ( ) [ ] < > |
7687
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( \$[\$\@\#\\\'\"\/\?\(\)\[\]\<\>] ) /oxmsgc) { |
7688
|
|
|
|
|
|
|
$e_string .= $1; |
7689
|
|
|
|
|
|
|
$slash = 'div'; |
7690
|
|
|
|
|
|
|
} |
7691
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7692
|
0
|
|
|
|
|
0
|
# subroutines of package Ehp15 |
|
0
|
|
|
|
|
0
|
|
7693
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b (CORE:: | ->(>?\s*) (?: atan2 | [a-z]{2,})) \b /oxgc) { $e_string .= $1; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7694
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7695
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b HP15::eval (?= (?>\s*) \{ ) /oxgc) { $e_string .= 'eval'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7696
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::eval \b /oxgc) { $e_string .= 'eval Char::escape'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7697
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b HP15::eval \b /oxgc) { $e_string .= 'eval HP15::escape'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7698
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::substr \b /oxgc) { $e_string .= 'substr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7699
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chop \b /oxgc) { $e_string .= 'Ehp15::chop'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7700
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::index \b /oxgc) { $e_string .= 'index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7701
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::index \b /oxgc) { $e_string .= 'Char::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7702
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b HP15::index \b /oxgc) { $e_string .= 'HP15::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7703
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b index \b /oxgc) { $e_string .= 'Ehp15::index'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7704
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::rindex \b /oxgc) { $e_string .= 'rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7705
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b Char::rindex \b /oxgc) { $e_string .= 'Char::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7706
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b HP15::rindex \b /oxgc) { $e_string .= 'HP15::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7707
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b rindex \b /oxgc) { $e_string .= 'Ehp15::rindex'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7708
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ehp15::lc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7709
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lcfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ehp15::lcfirst'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7710
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b uc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ehp15::uc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7711
|
|
|
|
|
|
|
elsif ($string =~ /\G \b ucfirst (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ehp15::ucfirst'; $slash = 'm//'; } |
7712
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b fc (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ehp15::fc'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7713
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
7714
|
0
|
|
|
|
|
0
|
(?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_qq('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7715
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7716
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7717
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7718
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
1
|
|
|
|
|
8
|
|
7719
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
7720
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
7721
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
6
|
|
7722
|
1
|
|
|
|
|
4
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
7723
|
0
|
|
|
|
|
0
|
(?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_q ('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7724
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7725
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7726
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7727
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
1
|
|
|
|
|
8
|
|
7728
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
7729
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $e_string .= "Ehp15::filetest(qw($1)," . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
7730
|
1
|
|
|
|
|
3
|
|
|
0
|
|
|
|
|
0
|
|
7731
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
7732
|
0
|
|
|
|
|
0
|
{ $e_string .= "Ehp15::filetest(qw($1),$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7733
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "Ehp15::filetest(qw($1),$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7734
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) (?= [a-z]+) /oxgc) { $e_string .= "Ehp15::filetest qw($1),"; $slash = 'm//'; } |
7735
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ((?:-[rwxoRWXOezfdlpSbcugkTB](?>\s+)){2,}) ((?>\w+)) /oxgc) { $e_string .= "Ehp15::filetest(qw($1),$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7736
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7737
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= "Ehp15::$1(" . e_qq('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7738
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $e_string .= "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7739
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $e_string .= "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7740
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $e_string .= "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7741
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
2
|
|
|
|
|
10
|
|
7742
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
7743
|
2
|
|
|
|
|
8
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\2) /oxgc) { $e_string .= "Ehp15::$1(" . e_qq('qq',$2,$4,$3) . ")"; $slash = 'm//'; } |
|
1
|
|
|
|
|
9
|
|
7744
|
1
|
|
|
|
|
4
|
|
|
0
|
|
|
|
|
0
|
|
7745
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= "Ehp15::$1(" . e_q ('', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7746
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $e_string .= "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7747
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $e_string .= "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7748
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $e_string .= "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7749
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
|
2
|
|
|
|
|
19
|
|
7750
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
7751
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) q (?>\s*) (\S) ((?:\\\2|\\\\|$q_char)+?) (\2) /oxgc) { $e_string .= "Ehp15::$1(" . e_q ('q', $2,$4,$3) . ")"; $slash = 'm//'; } |
7752
|
2
|
|
|
|
|
9
|
|
|
0
|
|
|
|
|
0
|
|
7753
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ) )*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
7754
|
0
|
|
|
|
|
0
|
{ $e_string .= "Ehp15::$1($2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7755
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "Ehp15::$1($2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7756
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= "Ehp15::$1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7757
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "Ehp15::$1(::"."$2)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7758
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -(t) (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-t $2"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7759
|
|
|
|
|
|
|
elsif ($string =~ /\G \b lstat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ehp15::lstat'; $slash = 'm//'; } |
7760
|
|
|
|
|
|
|
elsif ($string =~ /\G \b stat (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ehp15::stat'; $slash = 'm//'; } |
7761
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7762
|
0
|
|
|
|
|
0
|
# "-s '' ..." means file test "-s 'filename' ..." (not means "- s/// ...") |
|
0
|
|
|
|
|
0
|
|
7763
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\") ((?:$qq_char)+?) (\") /oxgc) { $e_string .= '-s ' . e_qq('', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7764
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\#) ((?:$qq_char)+?) (\#) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7765
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\() ((?:$qq_paren)+?) (\)) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7766
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\{) ((?:$qq_brace)+?) (\}) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7767
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\[) ((?:$qq_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7768
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\<) ((?:$qq_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
7769
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) qq (?>\s*) (\S) ((?:$qq_char)+?) (\1) /oxgc) { $e_string .= '-s ' . e_qq('qq',$1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7770
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7771
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\') ((?:\\\'|\\\\|$q_char)+?) (\') /oxgc) { $e_string .= '-s ' . e_q ('', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7772
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\#) ((?:\\\#|\\\\|$q_char)+?) (\#) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7773
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\() ((?:\\\)|\\\\|$q_paren)+?) (\)) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7774
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\{) ((?:\\\}|\\\\|$q_brace)+?) (\}) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7775
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\[) ((?:\\\]|\\\\|$q_bracket)+?) (\]) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7776
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\<) ((?:\\\>|\\\\|$q_angle)+?) (\>) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
7777
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?>\s+) q (?>\s*) (\S) ((?:\\\1|\\\\|$q_char)+?) (\1) /oxgc) { $e_string .= '-s ' . e_q ('q', $1,$3,$2); $slash = 'm//'; } |
7778
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7779
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) (\$ (?> \w+ (?: ::\w+)*) (?: (?: ->)? (?: [\$\@\%\&\*]\* | \$\#\* | \( (?:$qq_paren)*? \) | [\@\%\*]? \{ (?:$qq_brace)+? \} | [\@\%]? \[ (?:$qq_bracket)+? \] ))*) /oxgc) |
|
0
|
|
|
|
|
0
|
|
7780
|
0
|
|
|
|
|
0
|
{ $e_string .= "-s $1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7781
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s*) \( ((?:$qq_paren)*?) \) /oxgc) { $e_string .= "-s ($1)"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7782
|
|
|
|
|
|
|
elsif ($string =~ /\G -s (?= (?>\s+) [a-z]+) /oxgc) { $e_string .= '-s'; $slash = 'm//'; } |
7783
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s (?>\s+) ((?>\w+)) /oxgc) { $e_string .= "-s $1"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7784
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7785
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::length (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'length'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7786
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7787
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chr (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ehp15::chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7788
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'ord'; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
7789
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ord (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= $function_ord; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
7790
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b glob (?= (?>\s+)[A-Za-z_]|(?>\s*)['"`\$\@\&\*\(]) /oxgc) { $e_string .= 'Ehp15::glob'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7791
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lc \b /oxgc) { $e_string .= 'Ehp15::lc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7792
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b lcfirst \b /oxgc) { $e_string .= 'Ehp15::lcfirst_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7793
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b uc \b /oxgc) { $e_string .= 'Ehp15::uc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7794
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ucfirst \b /oxgc) { $e_string .= 'Ehp15::ucfirst_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7795
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b fc \b /oxgc) { $e_string .= 'Ehp15::fc_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7796
|
|
|
|
|
|
|
elsif ($string =~ /\G \b lstat \b /oxgc) { $e_string .= 'Ehp15::lstat_'; $slash = 'm//'; } |
7797
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b stat \b /oxgc) { $e_string .= 'Ehp15::stat_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7798
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (-[rwxoRWXOezfdlpSbcugkTB] (?>(?:\s+ -[rwxoRWXOezfdlpSbcugkTB])+)) |
|
0
|
|
|
|
|
0
|
|
7799
|
0
|
|
|
|
|
0
|
\b /oxgc) { $e_string .= "Ehp15::filetest_(qw($1))"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7800
|
|
|
|
|
|
|
elsif ($string =~ /\G -([rwxoRWXOezsfdlpSbcugkTBMAC]) \b /oxgc) { $e_string .= "Ehp15::${1}_"; $slash = 'm//'; } |
7801
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G -s \b /oxgc) { $e_string .= '-s '; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7802
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7803
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::length \b /oxgc) { $e_string .= 'length'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7804
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::chr \b /oxgc) { $e_string .= 'chr'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7805
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b chr \b /oxgc) { $e_string .= 'Ehp15::chr_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7806
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b bytes::ord \b /oxgc) { $e_string .= 'ord'; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
7807
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b ord \b /oxgc) { $e_string .= $function_ord_; $slash = 'div'; } |
|
0
|
|
|
|
|
0
|
|
7808
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b glob \b /oxgc) { $e_string .= 'Ehp15::glob_'; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7809
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b reverse \b /oxgc) { $e_string .= $function_reverse; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7810
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b getc \b /oxgc) { $e_string .= $function_getc; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7811
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b opendir ((?>\s*) \( (?>\s*)) (?=[A-Za-z_]) /oxgc) { $e_string .= "Ehp15::opendir$1*"; $slash = 'm//'; } |
|
0
|
|
|
|
|
0
|
|
7812
|
|
|
|
|
|
|
elsif ($string =~ /\G \b opendir ((?>\s+)) (?=[A-Za-z_]) /oxgc) { $e_string .= "Ehp15::opendir$1*"; $slash = 'm//'; } |
7813
|
|
|
|
|
|
|
elsif ($string =~ /\G \b unlink \b /oxgc) { $e_string .= 'Ehp15::unlink'; $slash = 'm//'; } |
7814
|
|
|
|
|
|
|
|
7815
|
0
|
|
|
|
|
0
|
# chdir |
7816
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (chdir) \b (?! (?>\s*) => ) /oxgc) { |
7817
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
7818
|
|
|
|
|
|
|
|
7819
|
0
|
|
|
|
|
0
|
$e_string .= 'Ehp15::chdir'; |
7820
|
0
|
|
|
|
|
0
|
|
7821
|
|
|
|
|
|
|
while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
7822
|
|
|
|
|
|
|
$e_string .= $1; |
7823
|
|
|
|
|
|
|
} |
7824
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7825
|
|
|
|
|
|
|
# end of chdir |
7826
|
|
|
|
|
|
|
if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return $e_string; } |
7827
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7828
|
|
|
|
|
|
|
# chdir scalar value |
7829
|
|
|
|
|
|
|
elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= e_string($1); next E_STRING_LOOP; } |
7830
|
|
|
|
|
|
|
|
7831
|
0
|
0
|
|
|
|
0
|
# chdir qq// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7832
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
7833
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq# # --> qr # # |
7834
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7835
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7836
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7837
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
7838
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
7839
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
7840
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq < > --> qr < > |
|
0
|
|
|
|
|
0
|
|
7841
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_chdir('qq','{','}',$2); next E_STRING_LOOP; } # qq | | --> qr { } |
7842
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_chdir('qq',$1,$3,$2); next E_STRING_LOOP; } # qq * * --> qr * * |
7843
|
|
|
|
|
|
|
} |
7844
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7845
|
|
|
|
|
|
|
} |
7846
|
|
|
|
|
|
|
} |
7847
|
|
|
|
|
|
|
|
7848
|
0
|
0
|
|
|
|
0
|
# chdir q// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7849
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
7850
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q# # --> qr # # |
7851
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7852
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7853
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7854
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
7855
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
7856
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
7857
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q < > --> qr < > |
|
0
|
|
|
|
|
0
|
|
7858
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_chdir_q('q','{','}',$2); next E_STRING_LOOP; } # q | | --> qr { } |
7859
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= e_chdir_q('q',$1,$3,$2); next E_STRING_LOOP; } # q * * --> qr * * |
7860
|
|
|
|
|
|
|
} |
7861
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7862
|
|
|
|
|
|
|
} |
7863
|
|
|
|
|
|
|
} |
7864
|
|
|
|
|
|
|
|
7865
|
0
|
|
|
|
|
0
|
# chdir '' |
7866
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') /oxgc) { |
7867
|
0
|
0
|
|
|
|
0
|
my $q_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7868
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
7869
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7870
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } |
7871
|
|
|
|
|
|
|
elsif ($string =~ /\G \' /oxgc) { $e_string .= e_chdir_q('',"'","'",$q_string); next E_STRING_LOOP; } |
7872
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; } |
7873
|
|
|
|
|
|
|
} |
7874
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7875
|
|
|
|
|
|
|
} |
7876
|
|
|
|
|
|
|
|
7877
|
0
|
|
|
|
|
0
|
# chdir "" |
7878
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\") /oxgc) { |
7879
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7880
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
7881
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7882
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } |
7883
|
|
|
|
|
|
|
elsif ($string =~ /\G \" /oxgc) { $e_string .= e_chdir('','"','"',$qq_string); next E_STRING_LOOP; } |
7884
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $qq_string .= $1; } |
7885
|
|
|
|
|
|
|
} |
7886
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7887
|
|
|
|
|
|
|
} |
7888
|
|
|
|
|
|
|
} |
7889
|
|
|
|
|
|
|
|
7890
|
0
|
|
|
|
|
0
|
# split |
7891
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (split) \b (?! (?>\s*) => ) /oxgc) { |
7892
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
7893
|
0
|
|
|
|
|
0
|
|
7894
|
0
|
|
|
|
|
0
|
my $e = ''; |
7895
|
|
|
|
|
|
|
while ($string =~ /\G ( (?>\s+) | \( | \#.* ) /oxgc) { |
7896
|
|
|
|
|
|
|
$e .= $1; |
7897
|
|
|
|
|
|
|
} |
7898
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7899
|
|
|
|
|
|
|
# end of split |
7900
|
|
|
|
|
|
|
if ($string =~ /\G (?= [,;\)\}\]] ) /oxgc) { return 'Ehp15::split' . $e; } |
7901
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7902
|
|
|
|
|
|
|
# split scalar value |
7903
|
|
|
|
|
|
|
elsif ($string =~ /\G ( [\$\@\&\*] $qq_scalar ) /oxgc) { $e_string .= 'Ehp15::split' . $e . e_string($1); next E_STRING_LOOP; } |
7904
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7905
|
0
|
|
|
|
|
0
|
# split literal space |
|
0
|
|
|
|
|
0
|
|
7906
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq (\#) [ ] (\#) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq {qq$1 $2}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7907
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7908
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7909
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7910
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7911
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b qq ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq{$1qq$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7912
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q (\#) [ ] (\#) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq {q$1 $2}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7913
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\() [ ] (\)) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7914
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\{) [ ] (\}) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7915
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\[) [ ] (\]) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7916
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\<) [ ] (\>) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7917
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G \b q ((?>\s*)) (\S) [ ] (\2) /oxgc) { $e_string .= 'Ehp15::split' . $e . qq {$1q$2 $3}; next E_STRING_LOOP; } |
|
0
|
|
|
|
|
0
|
|
7918
|
|
|
|
|
|
|
elsif ($string =~ /\G ' [ ] ' /oxgc) { $e_string .= 'Ehp15::split' . $e . qq {' '}; next E_STRING_LOOP; } |
7919
|
|
|
|
|
|
|
elsif ($string =~ /\G " [ ] " /oxgc) { $e_string .= 'Ehp15::split' . $e . qq {" "}; next E_STRING_LOOP; } |
7920
|
|
|
|
|
|
|
|
7921
|
0
|
0
|
|
|
|
0
|
# split qq// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7922
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
7923
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq# # --> qr # # |
7924
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7925
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7926
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
7927
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
7928
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
7929
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
7930
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq < > --> qr < > |
|
0
|
|
|
|
|
0
|
|
7931
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # qq | | --> qr { } |
7932
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= e_split($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # qq * * --> qr * * |
7933
|
|
|
|
|
|
|
} |
7934
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7935
|
|
|
|
|
|
|
} |
7936
|
|
|
|
|
|
|
} |
7937
|
|
|
|
|
|
|
|
7938
|
0
|
0
|
|
|
|
0
|
# split qr// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7939
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (qr) \b /oxgc) { |
7940
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1,$3,$2,$4); next E_STRING_LOOP; } # qr# # |
7941
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7942
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7943
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
7944
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr ( ) |
|
0
|
|
|
|
|
0
|
|
7945
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr { } |
|
0
|
|
|
|
|
0
|
|
7946
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr [ ] |
|
0
|
|
|
|
|
0
|
|
7947
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr < > |
|
0
|
|
|
|
|
0
|
|
7948
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr ' ' |
|
0
|
|
|
|
|
0
|
|
7949
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # qr | | --> qr { } |
7950
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) ([imosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # qr * * |
7951
|
|
|
|
|
|
|
} |
7952
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7953
|
|
|
|
|
|
|
} |
7954
|
|
|
|
|
|
|
} |
7955
|
|
|
|
|
|
|
|
7956
|
0
|
0
|
|
|
|
0
|
# split q// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7957
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
7958
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q# # --> qr # # |
7959
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7960
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7961
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
7962
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
7963
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
7964
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
7965
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q < > --> qr < > |
|
0
|
|
|
|
|
0
|
|
7966
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$q_char)*?) (\1) /oxgc) { $e_string .= e_split_q($e.'qr','{','}',$2,''); next E_STRING_LOOP; } # q | | --> qr { } |
7967
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= e_split_q($e.'qr',$1,$3,$2,''); next E_STRING_LOOP; } # q * * --> qr * * |
7968
|
|
|
|
|
|
|
} |
7969
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
7970
|
|
|
|
|
|
|
} |
7971
|
|
|
|
|
|
|
} |
7972
|
|
|
|
|
|
|
|
7973
|
0
|
0
|
|
|
|
0
|
# split m// |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
7974
|
|
|
|
|
|
|
elsif ($string =~ /\G \b (m) \b /oxgc) { |
7975
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1,$3,$2,$4); next E_STRING_LOOP; } # m# # --> qr # # |
7976
|
0
|
0
|
|
|
|
0
|
else { |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7977
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
7978
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e_string .= $e . $1; } |
|
0
|
|
|
|
|
0
|
|
7979
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m ( ) --> qr ( ) |
|
0
|
|
|
|
|
0
|
|
7980
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m { } --> qr { } |
|
0
|
|
|
|
|
0
|
|
7981
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m [ ] --> qr [ ] |
|
0
|
|
|
|
|
0
|
|
7982
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m < > --> qr < > |
|
0
|
|
|
|
|
0
|
|
7983
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split_q($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m ' ' --> qr ' ' |
|
0
|
|
|
|
|
0
|
|
7984
|
|
|
|
|
|
|
elsif ($string =~ /\G ([*\-:?\\^|]) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr','{','}',$2,$4); next E_STRING_LOOP; } # m | | --> qr { } |
7985
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split ($e.'qr',$1, $3, $2,$4); next E_STRING_LOOP; } # m * * --> qr * * |
7986
|
|
|
|
|
|
|
} |
7987
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
7988
|
|
|
|
|
|
|
} |
7989
|
|
|
|
|
|
|
} |
7990
|
|
|
|
|
|
|
|
7991
|
0
|
|
|
|
|
0
|
# split '' |
7992
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\') /oxgc) { |
7993
|
0
|
0
|
|
|
|
0
|
my $q_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
7994
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
7995
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $q_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
7996
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\') /oxgc) { $q_string .= $1; } # splitqr'' --> split qr'' |
7997
|
|
|
|
|
|
|
elsif ($string =~ /\G \' /oxgc) { $e_string .= e_split_q($e.q{ qr},"'","'",$q_string,''); next E_STRING_LOOP; } # ' ' --> qr ' ' |
7998
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $q_string .= $1; } |
7999
|
|
|
|
|
|
|
} |
8000
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8001
|
|
|
|
|
|
|
} |
8002
|
|
|
|
|
|
|
|
8003
|
0
|
|
|
|
|
0
|
# split "" |
8004
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\") /oxgc) { |
8005
|
0
|
0
|
|
|
|
0
|
my $qq_string = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8006
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
8007
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $qq_string .= $1; } |
|
0
|
|
|
|
|
0
|
|
8008
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\") /oxgc) { $qq_string .= $1; } # splitqr"" --> split qr"" |
8009
|
|
|
|
|
|
|
elsif ($string =~ /\G \" /oxgc) { $e_string .= e_split($e.q{ qr},'"','"',$qq_string,''); next E_STRING_LOOP; } # " " --> qr " " |
8010
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $qq_string .= $1; } |
8011
|
|
|
|
|
|
|
} |
8012
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8013
|
|
|
|
|
|
|
} |
8014
|
|
|
|
|
|
|
|
8015
|
0
|
|
|
|
|
0
|
# split // |
8016
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\/) /oxgc) { |
8017
|
0
|
0
|
|
|
|
0
|
my $regexp = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8018
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
8019
|
0
|
|
|
|
|
0
|
if ($string =~ /\G (\\\\) /oxgc) { $regexp .= $1; } |
|
0
|
|
|
|
|
0
|
|
8020
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\\\/) /oxgc) { $regexp .= $1; } # splitqr// --> split qr// |
8021
|
|
|
|
|
|
|
elsif ($string =~ /\G \/ ([cgimosxpadlunbB]*) /oxgc) { $e_string .= e_split($e.q{ qr}, '/','/',$regexp,$1); next E_STRING_LOOP; } # / / --> qr / / |
8022
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ($q_char) /oxgc) { $regexp .= $1; } |
8023
|
|
|
|
|
|
|
} |
8024
|
|
|
|
|
|
|
die __FILE__, ": Search pattern not terminated\n"; |
8025
|
|
|
|
|
|
|
} |
8026
|
|
|
|
|
|
|
} |
8027
|
|
|
|
|
|
|
|
8028
|
0
|
|
|
|
|
0
|
# qq// |
8029
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G \b (qq) \b /oxgc) { |
8030
|
0
|
|
|
|
|
0
|
my $ope = $1; |
8031
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qq# # |
8032
|
|
|
|
|
|
|
$e_string .= e_qq($ope,$1,$3,$2); |
8033
|
0
|
|
|
|
|
0
|
} |
8034
|
0
|
|
|
|
|
0
|
else { |
8035
|
0
|
0
|
|
|
|
0
|
my $e = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8036
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8037
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8038
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq ( ) |
|
0
|
|
|
|
|
0
|
|
8039
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq { } |
|
0
|
|
|
|
|
0
|
|
8040
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq [ ] |
|
0
|
|
|
|
|
0
|
|
8041
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq < > |
8042
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qq * * |
8043
|
|
|
|
|
|
|
} |
8044
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8045
|
|
|
|
|
|
|
} |
8046
|
|
|
|
|
|
|
} |
8047
|
|
|
|
|
|
|
|
8048
|
0
|
|
|
|
|
0
|
# qx// |
8049
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G \b (qx) \b /oxgc) { |
8050
|
0
|
|
|
|
|
0
|
my $ope = $1; |
8051
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:$qq_char)*?) (\#) /oxgc) { # qx# # |
8052
|
|
|
|
|
|
|
$e_string .= e_qq($ope,$1,$3,$2); |
8053
|
0
|
|
|
|
|
0
|
} |
8054
|
0
|
|
|
|
|
0
|
else { |
8055
|
0
|
0
|
|
|
|
0
|
my $e = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8056
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8057
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8058
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:$qq_paren)*?) (\)) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ( ) |
|
0
|
|
|
|
|
0
|
|
8059
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:$qq_brace)*?) (\}) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx { } |
|
0
|
|
|
|
|
0
|
|
8060
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:$qq_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx [ ] |
|
0
|
|
|
|
|
0
|
|
8061
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\<) ((?:$qq_angle)*?) (\>) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx < > |
|
0
|
|
|
|
|
0
|
|
8062
|
|
|
|
|
|
|
elsif ($string =~ /\G (\') ((?:$qq_char)*?) (\') /oxgc) { $e_string .= $e . e_q ($ope,$1,$3,$2); next E_STRING_LOOP; } # qx ' ' |
8063
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:$qq_char)*?) (\1) /oxgc) { $e_string .= $e . e_qq($ope,$1,$3,$2); next E_STRING_LOOP; } # qx * * |
8064
|
|
|
|
|
|
|
} |
8065
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8066
|
|
|
|
|
|
|
} |
8067
|
|
|
|
|
|
|
} |
8068
|
|
|
|
|
|
|
|
8069
|
0
|
|
|
|
|
0
|
# q// |
8070
|
0
|
0
|
|
|
|
0
|
elsif ($string =~ /\G \b (q) \b /oxgc) { |
8071
|
0
|
|
|
|
|
0
|
my $ope = $1; |
8072
|
|
|
|
|
|
|
if ($string =~ /\G (\#) ((?:\\\#|\\\\|$q_char)*?) (\#) /oxgc) { # q# # |
8073
|
|
|
|
|
|
|
$e_string .= e_q($ope,$1,$3,$2); |
8074
|
0
|
|
|
|
|
0
|
} |
8075
|
0
|
|
|
|
|
0
|
else { |
8076
|
0
|
0
|
|
|
|
0
|
my $e = ''; |
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8077
|
0
|
|
|
|
|
0
|
while ($string !~ /\G \z/oxgc) { |
|
0
|
|
|
|
|
0
|
|
8078
|
0
|
|
|
|
|
0
|
if ($string =~ /\G ((?>\s+)|\#.*) /oxgc) { $e .= $1; } |
|
0
|
|
|
|
|
0
|
|
8079
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\() ((?:\\\\|\\\)|\\\(|$q_paren)*?) (\)) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q ( ) |
|
0
|
|
|
|
|
0
|
|
8080
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\{) ((?:\\\\|\\\}|\\\{|$q_brace)*?) (\}) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q { } |
|
0
|
|
|
|
|
0
|
|
8081
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\[) ((?:\\\\|\\\]|\\\[|$q_bracket)*?) (\]) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q [ ] |
|
0
|
|
|
|
|
0
|
|
8082
|
|
|
|
|
|
|
elsif ($string =~ /\G (\<) ((?:\\\\|\\\>|\\\<|$q_angle)*?) (\>) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q < > |
8083
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G (\S) ((?:\\\\|\\\1| $q_char)*?) (\1) /oxgc) { $e_string .= $e . e_q($ope,$1,$3,$2); next E_STRING_LOOP; } # q * * |
8084
|
|
|
|
|
|
|
} |
8085
|
|
|
|
|
|
|
die __FILE__, ": Can't find string terminator anywhere before EOF\n"; |
8086
|
|
|
|
|
|
|
} |
8087
|
|
|
|
|
|
|
} |
8088
|
0
|
|
|
|
|
0
|
|
8089
|
|
|
|
|
|
|
# '' |
8090
|
|
|
|
|
|
|
elsif ($string =~ /\G (?
|
8091
|
44
|
|
|
|
|
185
|
|
8092
|
|
|
|
|
|
|
# "" |
8093
|
|
|
|
|
|
|
elsif ($string =~ /\G (\") ((?:$qq_char)*?) (\") /oxgc) { $e_string .= e_qq('',$1,$3,$2); } |
8094
|
6
|
|
|
|
|
65
|
|
8095
|
|
|
|
|
|
|
# `` |
8096
|
|
|
|
|
|
|
elsif ($string =~ /\G (\`) ((?:$qq_char)*?) (\`) /oxgc) { $e_string .= e_qq('',$1,$3,$2); } |
8097
|
0
|
|
|
|
|
0
|
|
8098
|
|
|
|
|
|
|
# <<>> (a safer ARGV) |
8099
|
|
|
|
|
|
|
elsif ($string =~ /\G ( <<>> ) /oxgc) { $e_string .= $1; } |
8100
|
0
|
|
|
|
|
0
|
|
8101
|
|
|
|
|
|
|
# <<= <=> <= < operator |
8102
|
|
|
|
|
|
|
elsif ($string =~ /\G ( <<= | <=> | <= | < ) (?= (?>\s*) [A-Za-z_0-9'"`\$\@\&\*\(\+\-] )/oxgc) { $e_string .= $1; } |
8103
|
0
|
|
|
|
|
0
|
|
8104
|
|
|
|
|
|
|
# |
8105
|
|
|
|
|
|
|
elsif ($string =~ /\G (<[\$]?[A-Za-z_][A-Za-z_0-9]*>) /oxgc) { $e_string .= $1; } |
8106
|
|
|
|
|
|
|
|
8107
|
0
|
|
|
|
|
0
|
# --- glob |
8108
|
|
|
|
|
|
|
elsif ($string =~ /\G < ((?:$q_char)+?) > /oxgc) { |
8109
|
|
|
|
|
|
|
$e_string .= 'Ehp15::glob("' . $1 . '")'; |
8110
|
|
|
|
|
|
|
} |
8111
|
|
|
|
|
|
|
|
8112
|
0
|
|
|
|
|
0
|
# << (bit shift) --- not here document |
8113
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << (?>\s*) ) (?= [0-9\$\@\&] ) /oxgc) { |
8114
|
|
|
|
|
|
|
$slash = 'm//'; |
8115
|
|
|
|
|
|
|
$e_string .= $1; |
8116
|
|
|
|
|
|
|
} |
8117
|
|
|
|
|
|
|
|
8118
|
0
|
|
|
|
|
0
|
# <<~'HEREDOC' |
8119
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* '([a-zA-Z_0-9]*)' ) /oxgc) { |
8120
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8121
|
|
|
|
|
|
|
my $here_quote = $1; |
8122
|
|
|
|
|
|
|
my $delimiter = $2; |
8123
|
0
|
0
|
|
|
|
0
|
|
8124
|
0
|
|
|
|
|
0
|
# get here document |
8125
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8126
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8127
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8128
|
0
|
|
|
|
|
0
|
} |
8129
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8130
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8131
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8132
|
0
|
|
|
|
|
0
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8133
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
8134
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8135
|
0
|
|
|
|
|
0
|
} |
8136
|
|
|
|
|
|
|
else { |
8137
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8138
|
|
|
|
|
|
|
} |
8139
|
|
|
|
|
|
|
$e_string .= qq{<<'$delimiter'}; |
8140
|
|
|
|
|
|
|
} |
8141
|
|
|
|
|
|
|
|
8142
|
0
|
|
|
|
|
0
|
# <<~\HEREDOC |
8143
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ \\([a-zA-Z_0-9]+) ) /oxgc) { |
8144
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8145
|
|
|
|
|
|
|
my $here_quote = $1; |
8146
|
|
|
|
|
|
|
my $delimiter = $2; |
8147
|
0
|
0
|
|
|
|
0
|
|
8148
|
0
|
|
|
|
|
0
|
# get here document |
8149
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8150
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8151
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8152
|
0
|
|
|
|
|
0
|
} |
8153
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8154
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8155
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8156
|
0
|
|
|
|
|
0
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8157
|
|
|
|
|
|
|
push @heredoc, $heredoc . qq{\n$delimiter\n}; |
8158
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8159
|
0
|
|
|
|
|
0
|
} |
8160
|
|
|
|
|
|
|
else { |
8161
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8162
|
|
|
|
|
|
|
} |
8163
|
|
|
|
|
|
|
$e_string .= qq{<<\\$delimiter}; |
8164
|
|
|
|
|
|
|
} |
8165
|
|
|
|
|
|
|
|
8166
|
0
|
|
|
|
|
0
|
# <<~"HEREDOC" |
8167
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* "([a-zA-Z_0-9]*)" ) /oxgc) { |
8168
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8169
|
|
|
|
|
|
|
my $here_quote = $1; |
8170
|
|
|
|
|
|
|
my $delimiter = $2; |
8171
|
0
|
0
|
|
|
|
0
|
|
8172
|
0
|
|
|
|
|
0
|
# get here document |
8173
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8174
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8175
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8176
|
0
|
|
|
|
|
0
|
} |
8177
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8178
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8179
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8180
|
0
|
|
|
|
|
0
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8181
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8182
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8183
|
0
|
|
|
|
|
0
|
} |
8184
|
|
|
|
|
|
|
else { |
8185
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8186
|
|
|
|
|
|
|
} |
8187
|
|
|
|
|
|
|
$e_string .= qq{<<"$delimiter"}; |
8188
|
|
|
|
|
|
|
} |
8189
|
|
|
|
|
|
|
|
8190
|
0
|
|
|
|
|
0
|
# <<~HEREDOC |
8191
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ ([a-zA-Z_0-9]+) ) /oxgc) { |
8192
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8193
|
|
|
|
|
|
|
my $here_quote = $1; |
8194
|
|
|
|
|
|
|
my $delimiter = $2; |
8195
|
0
|
0
|
|
|
|
0
|
|
8196
|
0
|
|
|
|
|
0
|
# get here document |
8197
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8198
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8199
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8200
|
0
|
|
|
|
|
0
|
} |
8201
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8202
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8203
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8204
|
0
|
|
|
|
|
0
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8205
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8206
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8207
|
0
|
|
|
|
|
0
|
} |
8208
|
|
|
|
|
|
|
else { |
8209
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8210
|
|
|
|
|
|
|
} |
8211
|
|
|
|
|
|
|
$e_string .= qq{<<$delimiter}; |
8212
|
|
|
|
|
|
|
} |
8213
|
|
|
|
|
|
|
|
8214
|
0
|
|
|
|
|
0
|
# <<~`HEREDOC` |
8215
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( <<~ [\t ]* `([a-zA-Z_0-9]*)` ) /oxgc) { |
8216
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8217
|
|
|
|
|
|
|
my $here_quote = $1; |
8218
|
|
|
|
|
|
|
my $delimiter = $2; |
8219
|
0
|
0
|
|
|
|
0
|
|
8220
|
0
|
|
|
|
|
0
|
# get here document |
8221
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8222
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8223
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8224
|
0
|
|
|
|
|
0
|
} |
8225
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n ([\t ]*) $delimiter \n //xms) { |
8226
|
0
|
|
|
|
|
0
|
my $heredoc = $1; |
8227
|
0
|
|
|
|
|
0
|
my $indent = $2; |
8228
|
0
|
|
|
|
|
0
|
$heredoc =~ s{^$indent}{}msg; # no /ox |
8229
|
|
|
|
|
|
|
push @heredoc, e_heredoc($heredoc) . qq{\n$delimiter\n}; |
8230
|
|
|
|
|
|
|
push @heredoc_delimiter, qq{\\s*$delimiter}; |
8231
|
0
|
|
|
|
|
0
|
} |
8232
|
|
|
|
|
|
|
else { |
8233
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8234
|
|
|
|
|
|
|
} |
8235
|
|
|
|
|
|
|
$e_string .= qq{<<`$delimiter`}; |
8236
|
|
|
|
|
|
|
} |
8237
|
|
|
|
|
|
|
|
8238
|
0
|
|
|
|
|
0
|
# <<'HEREDOC' |
8239
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << '([a-zA-Z_0-9]*)' ) /oxgc) { |
8240
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8241
|
|
|
|
|
|
|
my $here_quote = $1; |
8242
|
|
|
|
|
|
|
my $delimiter = $2; |
8243
|
0
|
0
|
|
|
|
0
|
|
8244
|
0
|
|
|
|
|
0
|
# get here document |
8245
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8246
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8247
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8248
|
0
|
|
|
|
|
0
|
} |
8249
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8250
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
8251
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
8252
|
0
|
|
|
|
|
0
|
} |
8253
|
|
|
|
|
|
|
else { |
8254
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8255
|
|
|
|
|
|
|
} |
8256
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8257
|
|
|
|
|
|
|
} |
8258
|
|
|
|
|
|
|
|
8259
|
0
|
|
|
|
|
0
|
# <<\HEREDOC |
8260
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << \\([a-zA-Z_0-9]+) ) /oxgc) { |
8261
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8262
|
|
|
|
|
|
|
my $here_quote = $1; |
8263
|
|
|
|
|
|
|
my $delimiter = $2; |
8264
|
0
|
0
|
|
|
|
0
|
|
8265
|
0
|
|
|
|
|
0
|
# get here document |
8266
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8267
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8268
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8269
|
0
|
|
|
|
|
0
|
} |
8270
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8271
|
|
|
|
|
|
|
push @heredoc, $1 . qq{\n$delimiter\n}; |
8272
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
8273
|
0
|
|
|
|
|
0
|
} |
8274
|
|
|
|
|
|
|
else { |
8275
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8276
|
|
|
|
|
|
|
} |
8277
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8278
|
|
|
|
|
|
|
} |
8279
|
|
|
|
|
|
|
|
8280
|
0
|
|
|
|
|
0
|
# <<"HEREDOC" |
8281
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << "([a-zA-Z_0-9]*)" ) /oxgc) { |
8282
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8283
|
|
|
|
|
|
|
my $here_quote = $1; |
8284
|
|
|
|
|
|
|
my $delimiter = $2; |
8285
|
0
|
0
|
|
|
|
0
|
|
8286
|
0
|
|
|
|
|
0
|
# get here document |
8287
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8288
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8289
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8290
|
0
|
|
|
|
|
0
|
} |
8291
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8292
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8293
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
8294
|
0
|
|
|
|
|
0
|
} |
8295
|
|
|
|
|
|
|
else { |
8296
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8297
|
|
|
|
|
|
|
} |
8298
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8299
|
|
|
|
|
|
|
} |
8300
|
|
|
|
|
|
|
|
8301
|
0
|
|
|
|
|
0
|
# <
|
8302
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << ([a-zA-Z_0-9]+) ) /oxgc) { |
8303
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8304
|
|
|
|
|
|
|
my $here_quote = $1; |
8305
|
|
|
|
|
|
|
my $delimiter = $2; |
8306
|
0
|
0
|
|
|
|
0
|
|
8307
|
0
|
|
|
|
|
0
|
# get here document |
8308
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8309
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8310
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8311
|
0
|
|
|
|
|
0
|
} |
8312
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8313
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8314
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
8315
|
0
|
|
|
|
|
0
|
} |
8316
|
|
|
|
|
|
|
else { |
8317
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8318
|
|
|
|
|
|
|
} |
8319
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8320
|
|
|
|
|
|
|
} |
8321
|
|
|
|
|
|
|
|
8322
|
0
|
|
|
|
|
0
|
# <<`HEREDOC` |
8323
|
0
|
|
|
|
|
0
|
elsif ($string =~ /\G ( << `([a-zA-Z_0-9]*)` ) /oxgc) { |
8324
|
0
|
|
|
|
|
0
|
$slash = 'm//'; |
8325
|
|
|
|
|
|
|
my $here_quote = $1; |
8326
|
|
|
|
|
|
|
my $delimiter = $2; |
8327
|
0
|
0
|
|
|
|
0
|
|
8328
|
0
|
|
|
|
|
0
|
# get here document |
8329
|
0
|
|
|
|
|
0
|
if ($here_script eq '') { |
8330
|
|
|
|
|
|
|
$here_script = CORE::substr $_, pos $_; |
8331
|
0
|
0
|
|
|
|
0
|
$here_script =~ s/.*?\n//oxm; |
8332
|
0
|
|
|
|
|
0
|
} |
8333
|
0
|
|
|
|
|
0
|
if ($here_script =~ s/\A (.*?) \n $delimiter \n //xms) { |
8334
|
|
|
|
|
|
|
push @heredoc, e_heredoc($1) . qq{\n$delimiter\n}; |
8335
|
|
|
|
|
|
|
push @heredoc_delimiter, $delimiter; |
8336
|
0
|
|
|
|
|
0
|
} |
8337
|
|
|
|
|
|
|
else { |
8338
|
0
|
|
|
|
|
0
|
die __FILE__, ": Can't find string terminator $delimiter anywhere before EOF\n"; |
8339
|
|
|
|
|
|
|
} |
8340
|
|
|
|
|
|
|
$e_string .= $here_quote; |
8341
|
|
|
|
|
|
|
} |
8342
|
|
|
|
|
|
|
|
8343
|
|
|
|
|
|
|
# any operator before div |
8344
|
|
|
|
|
|
|
elsif ($string =~ /\G ( |
8345
|
|
|
|
|
|
|
-- | \+\+ | |
8346
|
0
|
|
|
|
|
0
|
[\)\}\]] |
|
80
|
|
|
|
|
181
|
|
8347
|
|
|
|
|
|
|
|
8348
|
|
|
|
|
|
|
) /oxgc) { $slash = 'div'; $e_string .= $1; } |
8349
|
|
|
|
|
|
|
|
8350
|
|
|
|
|
|
|
# yada-yada or triple-dot operator |
8351
|
|
|
|
|
|
|
elsif ($string =~ /\G ( |
8352
|
80
|
|
|
|
|
291
|
\.\.\. |
|
0
|
|
|
|
|
0
|
|
8353
|
|
|
|
|
|
|
|
8354
|
|
|
|
|
|
|
) /oxgc) { $slash = 'm//'; $e_string .= q{die('Unimplemented')}; } |
8355
|
|
|
|
|
|
|
|
8356
|
|
|
|
|
|
|
# any operator before m// |
8357
|
|
|
|
|
|
|
elsif ($string =~ /\G ((?> |
8358
|
|
|
|
|
|
|
|
8359
|
|
|
|
|
|
|
!~~ | !~ | != | ! | |
8360
|
|
|
|
|
|
|
%= | % | |
8361
|
|
|
|
|
|
|
&&= | && | &= | &\.= | &\. | & | |
8362
|
|
|
|
|
|
|
-= | -> | - | |
8363
|
|
|
|
|
|
|
:(?>\s*)= | |
8364
|
|
|
|
|
|
|
: | |
8365
|
|
|
|
|
|
|
<<>> | |
8366
|
|
|
|
|
|
|
<<= | <=> | <= | < | |
8367
|
|
|
|
|
|
|
== | => | =~ | = | |
8368
|
|
|
|
|
|
|
>>= | >> | >= | > | |
8369
|
|
|
|
|
|
|
\*\*= | \*\* | \*= | \* | |
8370
|
|
|
|
|
|
|
\+= | \+ | |
8371
|
|
|
|
|
|
|
\.\. | \.= | \. | |
8372
|
|
|
|
|
|
|
\/\/= | \/\/ | |
8373
|
|
|
|
|
|
|
\/= | \/ | |
8374
|
|
|
|
|
|
|
\? | |
8375
|
|
|
|
|
|
|
\\ | |
8376
|
|
|
|
|
|
|
\^= | \^\.= | \^\. | \^ | |
8377
|
|
|
|
|
|
|
\b x= | |
8378
|
|
|
|
|
|
|
\|\|= | \|\| | \|= | \|\.= | \|\. | \| | |
8379
|
|
|
|
|
|
|
~~ | ~\. | ~ | |
8380
|
|
|
|
|
|
|
\b(?: and | cmp | eq | ge | gt | le | lt | ne | not | or | xor | x )\b | |
8381
|
|
|
|
|
|
|
\b(?: print )\b | |
8382
|
|
|
|
|
|
|
|
8383
|
0
|
|
|
|
|
0
|
[,;\(\{\[] |
|
112
|
|
|
|
|
290
|
|
8384
|
|
|
|
|
|
|
|
8385
|
|
|
|
|
|
|
)) /oxgc) { $slash = 'm//'; $e_string .= $1; } |
8386
|
112
|
|
|
|
|
1783
|
|
8387
|
|
|
|
|
|
|
# other any character |
8388
|
|
|
|
|
|
|
elsif ($string =~ /\G ($q_char) /oxgc) { $e_string .= $1; } |
8389
|
|
|
|
|
|
|
|
8390
|
353
|
|
|
|
|
2596
|
# system error |
8391
|
|
|
|
|
|
|
else { |
8392
|
|
|
|
|
|
|
die __FILE__, ": Oops, this shouldn't happen!\n"; |
8393
|
|
|
|
|
|
|
} |
8394
|
0
|
|
|
|
|
0
|
} |
8395
|
|
|
|
|
|
|
|
8396
|
|
|
|
|
|
|
return $e_string; |
8397
|
|
|
|
|
|
|
} |
8398
|
|
|
|
|
|
|
|
8399
|
|
|
|
|
|
|
# |
8400
|
|
|
|
|
|
|
# character class |
8401
|
79
|
|
|
5342
|
0
|
342
|
# |
8402
|
|
|
|
|
|
|
sub character_class { |
8403
|
5342
|
100
|
|
|
|
10183
|
my($char,$modifier) = @_; |
8404
|
5342
|
100
|
|
|
|
8596
|
|
8405
|
115
|
|
|
|
|
235
|
if ($char eq '.') { |
8406
|
|
|
|
|
|
|
if ($modifier =~ /s/) { |
8407
|
|
|
|
|
|
|
return '${Ehp15::dot_s}'; |
8408
|
23
|
|
|
|
|
63
|
} |
8409
|
|
|
|
|
|
|
else { |
8410
|
|
|
|
|
|
|
return '${Ehp15::dot}'; |
8411
|
|
|
|
|
|
|
} |
8412
|
92
|
|
|
|
|
193
|
} |
8413
|
|
|
|
|
|
|
else { |
8414
|
|
|
|
|
|
|
return Ehp15::classic_character_class($char); |
8415
|
|
|
|
|
|
|
} |
8416
|
|
|
|
|
|
|
} |
8417
|
|
|
|
|
|
|
|
8418
|
|
|
|
|
|
|
# |
8419
|
|
|
|
|
|
|
# escape capture ($1, $2, $3, ...) |
8420
|
|
|
|
|
|
|
# |
8421
|
5227
|
|
|
637
|
0
|
9219
|
sub e_capture { |
8422
|
637
|
|
|
|
|
2757
|
|
8423
|
|
|
|
|
|
|
return join '', '${Ehp15::capture(', $_[0], ')}'; |
8424
|
|
|
|
|
|
|
return join '', '${', $_[0], '}'; |
8425
|
|
|
|
|
|
|
} |
8426
|
|
|
|
|
|
|
|
8427
|
|
|
|
|
|
|
# |
8428
|
|
|
|
|
|
|
# escape transliteration (tr/// or y///) |
8429
|
0
|
|
|
11
|
0
|
0
|
# |
8430
|
11
|
|
|
|
|
58
|
sub e_tr { |
8431
|
11
|
|
100
|
|
|
29
|
my($variable,$charclass,$e,$charclass2,$modifier) = @_; |
8432
|
|
|
|
|
|
|
my $e_tr = ''; |
8433
|
11
|
|
|
|
|
38
|
$modifier ||= ''; |
8434
|
|
|
|
|
|
|
|
8435
|
|
|
|
|
|
|
$slash = 'div'; |
8436
|
11
|
|
|
|
|
17
|
|
8437
|
|
|
|
|
|
|
# quote character class 1 |
8438
|
|
|
|
|
|
|
$charclass = q_tr($charclass); |
8439
|
11
|
|
|
|
|
25
|
|
8440
|
|
|
|
|
|
|
# quote character class 2 |
8441
|
|
|
|
|
|
|
$charclass2 = q_tr($charclass2); |
8442
|
11
|
50
|
|
|
|
23
|
|
8443
|
11
|
0
|
|
|
|
34
|
# /b /B modifier |
8444
|
0
|
|
|
|
|
0
|
if ($modifier =~ tr/bB//d) { |
8445
|
|
|
|
|
|
|
if ($variable eq '') { |
8446
|
|
|
|
|
|
|
$e_tr = qq{tr$charclass$e$charclass2$modifier}; |
8447
|
0
|
|
|
|
|
0
|
} |
8448
|
|
|
|
|
|
|
else { |
8449
|
|
|
|
|
|
|
$e_tr = qq{$variable${bind_operator}tr$charclass$e$charclass2$modifier}; |
8450
|
|
|
|
|
|
|
} |
8451
|
0
|
100
|
|
|
|
0
|
} |
8452
|
11
|
|
|
|
|
22
|
else { |
8453
|
|
|
|
|
|
|
if ($variable eq '') { |
8454
|
|
|
|
|
|
|
$e_tr = qq{Ehp15::tr(\$_,' =~ ',$charclass,$e$charclass2,'$modifier')}; |
8455
|
2
|
|
|
|
|
7
|
} |
8456
|
|
|
|
|
|
|
else { |
8457
|
|
|
|
|
|
|
$e_tr = qq{Ehp15::tr($variable,'$bind_operator',$charclass,$e$charclass2,'$modifier')}; |
8458
|
|
|
|
|
|
|
} |
8459
|
|
|
|
|
|
|
} |
8460
|
9
|
|
|
|
|
29
|
|
8461
|
11
|
|
|
|
|
18
|
# clear tr/// variable |
8462
|
|
|
|
|
|
|
$tr_variable = ''; |
8463
|
11
|
|
|
|
|
13
|
$bind_operator = ''; |
8464
|
|
|
|
|
|
|
|
8465
|
|
|
|
|
|
|
return $e_tr; |
8466
|
|
|
|
|
|
|
} |
8467
|
|
|
|
|
|
|
|
8468
|
|
|
|
|
|
|
# |
8469
|
|
|
|
|
|
|
# quote for escape transliteration (tr/// or y///) |
8470
|
11
|
|
|
22
|
0
|
55
|
# |
8471
|
|
|
|
|
|
|
sub q_tr { |
8472
|
|
|
|
|
|
|
my($charclass) = @_; |
8473
|
22
|
50
|
|
|
|
29
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8474
|
22
|
|
|
|
|
47
|
# quote character class |
8475
|
|
|
|
|
|
|
if ($charclass !~ /'/oxms) { |
8476
|
|
|
|
|
|
|
return e_q('', "'", "'", $charclass); # --> q' ' |
8477
|
22
|
|
|
|
|
39
|
} |
8478
|
|
|
|
|
|
|
elsif ($charclass !~ /\//oxms) { |
8479
|
|
|
|
|
|
|
return e_q('q', '/', '/', $charclass); # --> q/ / |
8480
|
0
|
|
|
|
|
0
|
} |
8481
|
|
|
|
|
|
|
elsif ($charclass !~ /\#/oxms) { |
8482
|
|
|
|
|
|
|
return e_q('q', '#', '#', $charclass); # --> q# # |
8483
|
0
|
|
|
|
|
0
|
} |
8484
|
|
|
|
|
|
|
elsif ($charclass !~ /[\<\>]/oxms) { |
8485
|
|
|
|
|
|
|
return e_q('q', '<', '>', $charclass); # --> q< > |
8486
|
0
|
|
|
|
|
0
|
} |
8487
|
|
|
|
|
|
|
elsif ($charclass !~ /[\(\)]/oxms) { |
8488
|
|
|
|
|
|
|
return e_q('q', '(', ')', $charclass); # --> q( ) |
8489
|
0
|
|
|
|
|
0
|
} |
8490
|
|
|
|
|
|
|
elsif ($charclass !~ /[\{\}]/oxms) { |
8491
|
|
|
|
|
|
|
return e_q('q', '{', '}', $charclass); # --> q{ } |
8492
|
0
|
|
|
|
|
0
|
} |
8493
|
0
|
0
|
|
|
|
0
|
else { |
8494
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + . : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
8495
|
|
|
|
|
|
|
if ($charclass !~ /\Q$char\E/xms) { |
8496
|
|
|
|
|
|
|
return e_q('q', $char, $char, $charclass); |
8497
|
|
|
|
|
|
|
} |
8498
|
|
|
|
|
|
|
} |
8499
|
0
|
|
|
|
|
0
|
} |
8500
|
|
|
|
|
|
|
|
8501
|
|
|
|
|
|
|
return e_q('q', '{', '}', $charclass); |
8502
|
|
|
|
|
|
|
} |
8503
|
|
|
|
|
|
|
|
8504
|
|
|
|
|
|
|
# |
8505
|
|
|
|
|
|
|
# escape q string (q//, '') |
8506
|
0
|
|
|
3967
|
0
|
0
|
# |
8507
|
|
|
|
|
|
|
sub e_q { |
8508
|
3967
|
|
|
|
|
10279
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
8509
|
|
|
|
|
|
|
|
8510
|
3967
|
|
|
|
|
5833
|
$slash = 'div'; |
8511
|
3967
|
|
|
|
|
26217
|
|
8512
|
|
|
|
|
|
|
my @char = $string =~ / \G (?>$q_char) /oxmsg; |
8513
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
8514
|
3967
|
100
|
100
|
|
|
11446
|
|
|
|
100
|
100
|
|
|
|
|
8515
|
21219
|
|
|
|
|
125307
|
# escape last octet of multiple-octet |
8516
|
|
|
|
|
|
|
if ($char[$i] =~ /\A ([\x80-\xFF].*) (\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
8517
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
8518
|
1
|
|
|
|
|
6
|
} |
8519
|
|
|
|
|
|
|
elsif (defined($char[$i+1]) and ($char[$i+1] eq '\\') and ($char[$i] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
8520
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
8521
|
22
|
100
|
100
|
|
|
93
|
} |
8522
|
3967
|
|
|
|
|
15459
|
} |
8523
|
|
|
|
|
|
|
if (defined($char[-1]) and ($char[-1] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
8524
|
|
|
|
|
|
|
$char[-1] = $1 . '\\' . $2; |
8525
|
204
|
|
|
|
|
641
|
} |
8526
|
3967
|
|
|
|
|
21025
|
|
8527
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
8528
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $string, $end_delimiter; |
8529
|
|
|
|
|
|
|
} |
8530
|
|
|
|
|
|
|
|
8531
|
|
|
|
|
|
|
# |
8532
|
|
|
|
|
|
|
# escape qq string (qq//, "", qx//, ``) |
8533
|
0
|
|
|
9552
|
0
|
0
|
# |
8534
|
|
|
|
|
|
|
sub e_qq { |
8535
|
9552
|
|
|
|
|
29502
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
8536
|
|
|
|
|
|
|
|
8537
|
9552
|
|
|
|
|
13494
|
$slash = 'div'; |
8538
|
9552
|
|
|
|
|
12187
|
|
8539
|
|
|
|
|
|
|
my $left_e = 0; |
8540
|
|
|
|
|
|
|
my $right_e = 0; |
8541
|
9552
|
|
|
|
|
11594
|
|
8542
|
|
|
|
|
|
|
# split regexp |
8543
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
8544
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\$]|[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
8545
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
8546
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
8547
|
|
|
|
|
|
|
\\N\{ (?>[^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} | |
8548
|
|
|
|
|
|
|
\\ $q_char | |
8549
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
8550
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
8551
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
8552
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
8553
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
8554
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
8555
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
8556
|
|
|
|
|
|
|
$q_char |
8557
|
9552
|
|
|
|
|
385927
|
))/oxmsg; |
8558
|
|
|
|
|
|
|
|
8559
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
8560
|
9552
|
50
|
66
|
|
|
29415
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8561
|
307986
|
|
|
|
|
998640
|
# "\L\u" --> "\u\L" |
8562
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
8563
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8564
|
|
|
|
|
|
|
} |
8565
|
|
|
|
|
|
|
|
8566
|
0
|
|
|
|
|
0
|
# "\U\l" --> "\l\U" |
8567
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
8568
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8569
|
|
|
|
|
|
|
} |
8570
|
|
|
|
|
|
|
|
8571
|
0
|
|
|
|
|
0
|
# octal escape sequence |
8572
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
8573
|
|
|
|
|
|
|
$char[$i] = Ehp15::octchr($1); |
8574
|
|
|
|
|
|
|
} |
8575
|
|
|
|
|
|
|
|
8576
|
1
|
|
|
|
|
4
|
# hexadecimal escape sequence |
8577
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
8578
|
|
|
|
|
|
|
$char[$i] = Ehp15::hexchr($1); |
8579
|
|
|
|
|
|
|
} |
8580
|
|
|
|
|
|
|
|
8581
|
1
|
|
|
|
|
5
|
# \N{CHARNAME} --> N{CHARNAME} |
8582
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( N\{ ([^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} ) \z/oxms) { |
8583
|
|
|
|
|
|
|
$char[$i] = $1; |
8584
|
0
|
100
|
|
|
|
0
|
} |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8585
|
|
|
|
|
|
|
|
8586
|
|
|
|
|
|
|
if (0) { |
8587
|
|
|
|
|
|
|
} |
8588
|
|
|
|
|
|
|
|
8589
|
|
|
|
|
|
|
# escape last octet of multiple-octet |
8590
|
307986
|
|
|
|
|
2967681
|
# my $metachar = qr/[\@\\\|]/oxms; # '|' is for qx//, ``, open(), and system() |
8591
|
0
|
|
|
|
|
0
|
# variable $delimiter and $end_delimiter can be '' |
8592
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\@\\\|$delimiter$end_delimiter]) \z/xms) { |
8593
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
8594
|
|
|
|
|
|
|
} |
8595
|
|
|
|
|
|
|
|
8596
|
|
|
|
|
|
|
# \F |
8597
|
|
|
|
|
|
|
# |
8598
|
|
|
|
|
|
|
# P.69 Table 2-6. Translation escapes |
8599
|
|
|
|
|
|
|
# in Chapter 2: Bits and Pieces |
8600
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
8601
|
|
|
|
|
|
|
# (and so on) |
8602
|
|
|
|
|
|
|
|
8603
|
1342
|
50
|
|
|
|
4678
|
# \u \l \U \L \F \Q \E |
8604
|
647
|
|
|
|
|
1823
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
8605
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
8606
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
8607
|
|
|
|
|
|
|
} |
8608
|
|
|
|
|
|
|
} |
8609
|
|
|
|
|
|
|
elsif ($char[$i] eq '\u') { |
8610
|
|
|
|
|
|
|
|
8611
|
|
|
|
|
|
|
# "STRING @{[ LIST EXPR ]} MORE STRING" |
8612
|
|
|
|
|
|
|
|
8613
|
|
|
|
|
|
|
# P.257 Other Tricks You Can Do with Hard References |
8614
|
|
|
|
|
|
|
# in Chapter 8: References |
8615
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
8616
|
|
|
|
|
|
|
|
8617
|
|
|
|
|
|
|
# P.353 Other Tricks You Can Do with Hard References |
8618
|
|
|
|
|
|
|
# in Chapter 8: References |
8619
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
8620
|
|
|
|
|
|
|
|
8621
|
0
|
|
|
|
|
0
|
# (and so on) |
8622
|
0
|
|
|
|
|
0
|
|
8623
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ucfirst qq<'; |
8624
|
|
|
|
|
|
|
$left_e++; |
8625
|
0
|
|
|
|
|
0
|
} |
8626
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\l') { |
8627
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::lcfirst qq<'; |
8628
|
|
|
|
|
|
|
$left_e++; |
8629
|
0
|
|
|
|
|
0
|
} |
8630
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\U') { |
8631
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::uc qq<'; |
8632
|
|
|
|
|
|
|
$left_e++; |
8633
|
0
|
|
|
|
|
0
|
} |
8634
|
6
|
|
|
|
|
10
|
elsif ($char[$i] eq '\L') { |
8635
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::lc qq<'; |
8636
|
|
|
|
|
|
|
$left_e++; |
8637
|
6
|
|
|
|
|
13
|
} |
8638
|
9
|
|
|
|
|
21
|
elsif ($char[$i] eq '\F') { |
8639
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::fc qq<'; |
8640
|
|
|
|
|
|
|
$left_e++; |
8641
|
9
|
|
|
|
|
19
|
} |
8642
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
8643
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
8644
|
|
|
|
|
|
|
$left_e++; |
8645
|
0
|
50
|
|
|
|
0
|
} |
8646
|
12
|
|
|
|
|
26
|
elsif ($char[$i] eq '\E') { |
8647
|
12
|
|
|
|
|
15
|
if ($right_e < $left_e) { |
8648
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
8649
|
|
|
|
|
|
|
$right_e++; |
8650
|
12
|
|
|
|
|
26
|
} |
8651
|
|
|
|
|
|
|
else { |
8652
|
|
|
|
|
|
|
$char[$i] = ''; |
8653
|
|
|
|
|
|
|
} |
8654
|
0
|
|
|
|
|
0
|
} |
8655
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
8656
|
0
|
|
|
|
|
0
|
while (1) { |
8657
|
|
|
|
|
|
|
if (++$i > $#char) { |
8658
|
0
|
0
|
|
|
|
0
|
last; |
8659
|
0
|
|
|
|
|
0
|
} |
8660
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
8661
|
|
|
|
|
|
|
last; |
8662
|
|
|
|
|
|
|
} |
8663
|
|
|
|
|
|
|
} |
8664
|
|
|
|
|
|
|
} |
8665
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
8666
|
|
|
|
|
|
|
} |
8667
|
|
|
|
|
|
|
|
8668
|
|
|
|
|
|
|
# $0 --> $0 |
8669
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
8670
|
|
|
|
|
|
|
} |
8671
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
8672
|
|
|
|
|
|
|
} |
8673
|
|
|
|
|
|
|
|
8674
|
|
|
|
|
|
|
# $$ --> $$ |
8675
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
8676
|
|
|
|
|
|
|
} |
8677
|
|
|
|
|
|
|
|
8678
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
8679
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
8680
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
8681
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8682
|
415
|
|
|
|
|
1045
|
} |
8683
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
8684
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8685
|
|
|
|
|
|
|
} |
8686
|
|
|
|
|
|
|
|
8687
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
8688
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
8689
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
8690
|
|
|
|
|
|
|
} |
8691
|
|
|
|
|
|
|
|
8692
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
8693
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
8694
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
8695
|
|
|
|
|
|
|
} |
8696
|
|
|
|
|
|
|
|
8697
|
0
|
|
|
|
|
0
|
# $$foo |
8698
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
8699
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8700
|
|
|
|
|
|
|
} |
8701
|
|
|
|
|
|
|
|
8702
|
0
|
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ehp15::PREMATCH() |
8703
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
8704
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::PREMATCH()]}'; |
8705
|
|
|
|
|
|
|
} |
8706
|
|
|
|
|
|
|
|
8707
|
44
|
|
|
|
|
144
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ehp15::MATCH() |
8708
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
8709
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::MATCH()]}'; |
8710
|
|
|
|
|
|
|
} |
8711
|
|
|
|
|
|
|
|
8712
|
45
|
|
|
|
|
141
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ehp15::POSTMATCH() |
8713
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
8714
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::POSTMATCH()]}'; |
8715
|
|
|
|
|
|
|
} |
8716
|
|
|
|
|
|
|
|
8717
|
|
|
|
|
|
|
# ${ foo } --> ${ foo } |
8718
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) { |
8719
|
|
|
|
|
|
|
} |
8720
|
|
|
|
|
|
|
|
8721
|
33
|
|
|
|
|
112
|
# ${ ... } |
8722
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
8723
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8724
|
|
|
|
|
|
|
} |
8725
|
|
|
|
|
|
|
} |
8726
|
0
|
100
|
|
|
|
0
|
|
8727
|
9552
|
|
|
|
|
20746
|
# return string |
8728
|
|
|
|
|
|
|
if ($left_e > $right_e) { |
8729
|
3
|
|
|
|
|
20
|
return join '', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter; |
8730
|
|
|
|
|
|
|
} |
8731
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
8732
|
|
|
|
|
|
|
} |
8733
|
|
|
|
|
|
|
|
8734
|
|
|
|
|
|
|
# |
8735
|
|
|
|
|
|
|
# escape qw string (qw//) |
8736
|
9549
|
|
|
34
|
0
|
80348
|
# |
8737
|
|
|
|
|
|
|
sub e_qw { |
8738
|
34
|
|
|
|
|
174
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
8739
|
|
|
|
|
|
|
|
8740
|
|
|
|
|
|
|
$slash = 'div'; |
8741
|
34
|
|
|
|
|
90
|
|
|
34
|
|
|
|
|
353
|
|
8742
|
621
|
50
|
|
|
|
1106
|
# choice again delimiter |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8743
|
34
|
|
|
|
|
198
|
my %octet = map {$_ => 1} ($string =~ /\G ([\x00-\xFF]) /oxmsg); |
8744
|
|
|
|
|
|
|
if (not $octet{$end_delimiter}) { |
8745
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $string, $end_delimiter; |
8746
|
34
|
|
|
|
|
254
|
} |
8747
|
|
|
|
|
|
|
elsif (not $octet{')'}) { |
8748
|
|
|
|
|
|
|
return join '', $ope, '(', $string, ')'; |
8749
|
0
|
|
|
|
|
0
|
} |
8750
|
|
|
|
|
|
|
elsif (not $octet{'}'}) { |
8751
|
|
|
|
|
|
|
return join '', $ope, '{', $string, '}'; |
8752
|
0
|
|
|
|
|
0
|
} |
8753
|
|
|
|
|
|
|
elsif (not $octet{']'}) { |
8754
|
|
|
|
|
|
|
return join '', $ope, '[', $string, ']'; |
8755
|
0
|
|
|
|
|
0
|
} |
8756
|
|
|
|
|
|
|
elsif (not $octet{'>'}) { |
8757
|
|
|
|
|
|
|
return join '', $ope, '<', $string, '>'; |
8758
|
0
|
|
|
|
|
0
|
} |
8759
|
0
|
0
|
|
|
|
0
|
else { |
8760
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
8761
|
|
|
|
|
|
|
if (not $octet{$char}) { |
8762
|
|
|
|
|
|
|
return join '', $ope, $char, $string, $char; |
8763
|
|
|
|
|
|
|
} |
8764
|
|
|
|
|
|
|
} |
8765
|
|
|
|
|
|
|
} |
8766
|
0
|
|
|
|
|
0
|
|
8767
|
0
|
|
|
|
|
0
|
# qw/AAA BBB C'CC/ --> ('AAA', 'BBB', 'C\'CC') |
8768
|
0
|
|
|
|
|
0
|
my @string = CORE::split(/\s+/, $string); |
8769
|
0
|
|
|
|
|
0
|
for my $string (@string) { |
8770
|
0
|
0
|
|
|
|
0
|
my @octet = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
8771
|
0
|
|
|
|
|
0
|
for my $octet (@octet) { |
8772
|
|
|
|
|
|
|
if ($octet =~ /\A (['\\]) \z/oxms) { |
8773
|
|
|
|
|
|
|
$octet = '\\' . $1; |
8774
|
0
|
|
|
|
|
0
|
} |
8775
|
|
|
|
|
|
|
} |
8776
|
0
|
|
|
|
|
0
|
$string = join '', @octet; |
|
0
|
|
|
|
|
0
|
|
8777
|
|
|
|
|
|
|
} |
8778
|
|
|
|
|
|
|
return join '', '(', (join ', ', map { "'$_'" } @string), ')'; |
8779
|
|
|
|
|
|
|
} |
8780
|
|
|
|
|
|
|
|
8781
|
|
|
|
|
|
|
# |
8782
|
|
|
|
|
|
|
# escape here document (<<"HEREDOC", <
|
8783
|
0
|
|
|
108
|
0
|
0
|
# |
8784
|
|
|
|
|
|
|
sub e_heredoc { |
8785
|
108
|
|
|
|
|
291
|
my($string) = @_; |
8786
|
|
|
|
|
|
|
|
8787
|
108
|
|
|
|
|
172
|
$slash = 'm//'; |
8788
|
|
|
|
|
|
|
|
8789
|
108
|
|
|
|
|
371
|
my $metachar = qr/[\@\\|]/oxms; # '|' is for <<`HEREDOC` |
8790
|
108
|
|
|
|
|
168
|
|
8791
|
|
|
|
|
|
|
my $left_e = 0; |
8792
|
|
|
|
|
|
|
my $right_e = 0; |
8793
|
108
|
|
|
|
|
167
|
|
8794
|
|
|
|
|
|
|
# split regexp |
8795
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
8796
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\$]|[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
8797
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
8798
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
8799
|
|
|
|
|
|
|
\\N\{ (?>[^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} | |
8800
|
|
|
|
|
|
|
\\ $q_char | |
8801
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
8802
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
8803
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
8804
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
8805
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
8806
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
8807
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
8808
|
|
|
|
|
|
|
$q_char |
8809
|
108
|
|
|
|
|
10674
|
))/oxmsg; |
8810
|
|
|
|
|
|
|
|
8811
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
8812
|
108
|
50
|
66
|
|
|
546
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8813
|
3225
|
|
|
|
|
9684
|
# "\L\u" --> "\u\L" |
8814
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
8815
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8816
|
|
|
|
|
|
|
} |
8817
|
|
|
|
|
|
|
|
8818
|
0
|
|
|
|
|
0
|
# "\U\l" --> "\l\U" |
8819
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
8820
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
8821
|
|
|
|
|
|
|
} |
8822
|
|
|
|
|
|
|
|
8823
|
0
|
|
|
|
|
0
|
# octal escape sequence |
8824
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
8825
|
|
|
|
|
|
|
$char[$i] = Ehp15::octchr($1); |
8826
|
|
|
|
|
|
|
} |
8827
|
|
|
|
|
|
|
|
8828
|
1
|
|
|
|
|
4
|
# hexadecimal escape sequence |
8829
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
8830
|
|
|
|
|
|
|
$char[$i] = Ehp15::hexchr($1); |
8831
|
|
|
|
|
|
|
} |
8832
|
|
|
|
|
|
|
|
8833
|
1
|
|
|
|
|
3
|
# \N{CHARNAME} --> N{CHARNAME} |
8834
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( N\{ ([^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} ) \z/oxms) { |
8835
|
|
|
|
|
|
|
$char[$i] = $1; |
8836
|
0
|
100
|
|
|
|
0
|
} |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
8837
|
|
|
|
|
|
|
|
8838
|
|
|
|
|
|
|
if (0) { |
8839
|
|
|
|
|
|
|
} |
8840
|
3225
|
|
|
|
|
27350
|
|
8841
|
0
|
|
|
|
|
0
|
# escape character |
8842
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ($metachar) \z/oxms) { |
8843
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
8844
|
|
|
|
|
|
|
} |
8845
|
|
|
|
|
|
|
|
8846
|
57
|
50
|
|
|
|
219
|
# \u \l \U \L \F \Q \E |
8847
|
72
|
|
|
|
|
135
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
8848
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
8849
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
8850
|
|
|
|
|
|
|
} |
8851
|
0
|
|
|
|
|
0
|
} |
8852
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\u') { |
8853
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ucfirst qq<'; |
8854
|
|
|
|
|
|
|
$left_e++; |
8855
|
0
|
|
|
|
|
0
|
} |
8856
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\l') { |
8857
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::lcfirst qq<'; |
8858
|
|
|
|
|
|
|
$left_e++; |
8859
|
0
|
|
|
|
|
0
|
} |
8860
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\U') { |
8861
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::uc qq<'; |
8862
|
|
|
|
|
|
|
$left_e++; |
8863
|
0
|
|
|
|
|
0
|
} |
8864
|
6
|
|
|
|
|
12
|
elsif ($char[$i] eq '\L') { |
8865
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::lc qq<'; |
8866
|
|
|
|
|
|
|
$left_e++; |
8867
|
6
|
|
|
|
|
8
|
} |
8868
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\F') { |
8869
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::fc qq<'; |
8870
|
|
|
|
|
|
|
$left_e++; |
8871
|
0
|
|
|
|
|
0
|
} |
8872
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
8873
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
8874
|
|
|
|
|
|
|
$left_e++; |
8875
|
0
|
50
|
|
|
|
0
|
} |
8876
|
3
|
|
|
|
|
7
|
elsif ($char[$i] eq '\E') { |
8877
|
3
|
|
|
|
|
5
|
if ($right_e < $left_e) { |
8878
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
8879
|
|
|
|
|
|
|
$right_e++; |
8880
|
3
|
|
|
|
|
7
|
} |
8881
|
|
|
|
|
|
|
else { |
8882
|
|
|
|
|
|
|
$char[$i] = ''; |
8883
|
|
|
|
|
|
|
} |
8884
|
0
|
|
|
|
|
0
|
} |
8885
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
8886
|
0
|
|
|
|
|
0
|
while (1) { |
8887
|
|
|
|
|
|
|
if (++$i > $#char) { |
8888
|
0
|
0
|
|
|
|
0
|
last; |
8889
|
0
|
|
|
|
|
0
|
} |
8890
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
8891
|
|
|
|
|
|
|
last; |
8892
|
|
|
|
|
|
|
} |
8893
|
|
|
|
|
|
|
} |
8894
|
|
|
|
|
|
|
} |
8895
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
8896
|
|
|
|
|
|
|
} |
8897
|
|
|
|
|
|
|
|
8898
|
|
|
|
|
|
|
# $0 --> $0 |
8899
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
8900
|
|
|
|
|
|
|
} |
8901
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
8902
|
|
|
|
|
|
|
} |
8903
|
|
|
|
|
|
|
|
8904
|
|
|
|
|
|
|
# $$ --> $$ |
8905
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
8906
|
|
|
|
|
|
|
} |
8907
|
|
|
|
|
|
|
|
8908
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
8909
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
8910
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
8911
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8912
|
0
|
|
|
|
|
0
|
} |
8913
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
8914
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8915
|
|
|
|
|
|
|
} |
8916
|
|
|
|
|
|
|
|
8917
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
8918
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
8919
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
8920
|
|
|
|
|
|
|
} |
8921
|
|
|
|
|
|
|
|
8922
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
8923
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
8924
|
|
|
|
|
|
|
$char[$i] = e_capture($1.'->'.$2); |
8925
|
|
|
|
|
|
|
} |
8926
|
|
|
|
|
|
|
|
8927
|
0
|
|
|
|
|
0
|
# $$foo |
8928
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
8929
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8930
|
|
|
|
|
|
|
} |
8931
|
|
|
|
|
|
|
|
8932
|
0
|
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ehp15::PREMATCH() |
8933
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
8934
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::PREMATCH()]}'; |
8935
|
|
|
|
|
|
|
} |
8936
|
|
|
|
|
|
|
|
8937
|
8
|
|
|
|
|
45
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ehp15::MATCH() |
8938
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
8939
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::MATCH()]}'; |
8940
|
|
|
|
|
|
|
} |
8941
|
|
|
|
|
|
|
|
8942
|
8
|
|
|
|
|
50
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ehp15::POSTMATCH() |
8943
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
8944
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::POSTMATCH()]}'; |
8945
|
|
|
|
|
|
|
} |
8946
|
|
|
|
|
|
|
|
8947
|
|
|
|
|
|
|
# ${ foo } --> ${ foo } |
8948
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ (?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* ) \} \z/oxms) { |
8949
|
|
|
|
|
|
|
} |
8950
|
|
|
|
|
|
|
|
8951
|
6
|
|
|
|
|
39
|
# ${ ... } |
8952
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
8953
|
|
|
|
|
|
|
$char[$i] = e_capture($1); |
8954
|
|
|
|
|
|
|
} |
8955
|
|
|
|
|
|
|
} |
8956
|
0
|
100
|
|
|
|
0
|
|
8957
|
108
|
|
|
|
|
267
|
# return string |
8958
|
|
|
|
|
|
|
if ($left_e > $right_e) { |
8959
|
3
|
|
|
|
|
73
|
return join '', @char, '>]}' x ($left_e - $right_e); |
8960
|
|
|
|
|
|
|
} |
8961
|
|
|
|
|
|
|
return join '', @char; |
8962
|
|
|
|
|
|
|
} |
8963
|
|
|
|
|
|
|
|
8964
|
|
|
|
|
|
|
# |
8965
|
|
|
|
|
|
|
# escape regexp (m//, qr//) |
8966
|
105
|
|
|
1835
|
0
|
824
|
# |
8967
|
1835
|
|
100
|
|
|
8047
|
sub e_qr { |
8968
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
8969
|
1835
|
|
|
|
|
6593
|
$modifier ||= ''; |
8970
|
1835
|
50
|
|
|
|
3482
|
|
8971
|
1835
|
|
|
|
|
4858
|
$modifier =~ tr/p//d; |
8972
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
8973
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
8974
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
8975
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
8976
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
8977
|
|
|
|
|
|
|
last; |
8978
|
0
|
|
|
|
|
0
|
} |
8979
|
|
|
|
|
|
|
} |
8980
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
8981
|
0
|
|
|
|
|
0
|
} |
8982
|
|
|
|
|
|
|
|
8983
|
|
|
|
|
|
|
$slash = 'div'; |
8984
|
1835
|
100
|
|
|
|
3092
|
|
|
|
100
|
|
|
|
|
|
8985
|
1835
|
|
|
|
|
5618
|
# literal null string pattern |
8986
|
8
|
|
|
|
|
10
|
if ($string eq '') { |
8987
|
8
|
|
|
|
|
8
|
$modifier =~ tr/bB//d; |
8988
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
8989
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
8990
|
|
|
|
|
|
|
} |
8991
|
|
|
|
|
|
|
|
8992
|
|
|
|
|
|
|
# /b /B modifier |
8993
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
8994
|
8
|
50
|
|
|
|
40
|
|
8995
|
240
|
|
|
|
|
564
|
# choice again delimiter |
8996
|
0
|
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
0
|
|
|
|
|
0
|
|
8997
|
0
|
0
|
|
|
|
0
|
my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
8998
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
8999
|
0
|
|
|
|
|
0
|
if (not $octet{')'}) { |
9000
|
|
|
|
|
|
|
$delimiter = '('; |
9001
|
|
|
|
|
|
|
$end_delimiter = ')'; |
9002
|
0
|
|
|
|
|
0
|
} |
9003
|
0
|
|
|
|
|
0
|
elsif (not $octet{'}'}) { |
9004
|
|
|
|
|
|
|
$delimiter = '{'; |
9005
|
|
|
|
|
|
|
$end_delimiter = '}'; |
9006
|
0
|
|
|
|
|
0
|
} |
9007
|
0
|
|
|
|
|
0
|
elsif (not $octet{']'}) { |
9008
|
|
|
|
|
|
|
$delimiter = '['; |
9009
|
|
|
|
|
|
|
$end_delimiter = ']'; |
9010
|
0
|
|
|
|
|
0
|
} |
9011
|
0
|
|
|
|
|
0
|
elsif (not $octet{'>'}) { |
9012
|
|
|
|
|
|
|
$delimiter = '<'; |
9013
|
|
|
|
|
|
|
$end_delimiter = '>'; |
9014
|
0
|
|
|
|
|
0
|
} |
9015
|
0
|
0
|
|
|
|
0
|
else { |
9016
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9017
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9018
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
9019
|
|
|
|
|
|
|
$end_delimiter = $char; |
9020
|
|
|
|
|
|
|
last; |
9021
|
|
|
|
|
|
|
} |
9022
|
|
|
|
|
|
|
} |
9023
|
|
|
|
|
|
|
} |
9024
|
0
|
100
|
100
|
|
|
0
|
} |
9025
|
240
|
|
|
|
|
1039
|
|
9026
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9027
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $string, $matched, $end_delimiter, $modifier; |
9028
|
90
|
|
|
|
|
473
|
} |
9029
|
|
|
|
|
|
|
else { |
9030
|
|
|
|
|
|
|
return join '', $ope, $delimiter, '(?:', $string, ')', $matched, $end_delimiter, $modifier; |
9031
|
|
|
|
|
|
|
} |
9032
|
150
|
100
|
|
|
|
795
|
} |
9033
|
1587
|
|
|
|
|
4176
|
|
9034
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
9035
|
|
|
|
|
|
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
9036
|
1587
|
|
|
|
|
5520
|
|
9037
|
|
|
|
|
|
|
# split regexp |
9038
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9039
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\$\@\[\(]|[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
9040
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
9041
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
9042
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
9043
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
9044
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
9045
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} | |
9046
|
|
|
|
|
|
|
\\ $q_char | |
9047
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
9048
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
9049
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
9050
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
9051
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
9052
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
9053
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
9054
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
9055
|
|
|
|
|
|
|
\[\^ | |
9056
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
9057
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
9058
|
|
|
|
|
|
|
\(\? | |
9059
|
|
|
|
|
|
|
$q_char |
9060
|
|
|
|
|
|
|
))/oxmsg; |
9061
|
1587
|
50
|
|
|
|
140114
|
|
9062
|
1587
|
|
|
|
|
7236
|
# choice again delimiter |
|
0
|
|
|
|
|
0
|
|
9063
|
0
|
0
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9064
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9065
|
0
|
|
|
|
|
0
|
if (not $octet{')'}) { |
9066
|
|
|
|
|
|
|
$delimiter = '('; |
9067
|
|
|
|
|
|
|
$end_delimiter = ')'; |
9068
|
0
|
|
|
|
|
0
|
} |
9069
|
0
|
|
|
|
|
0
|
elsif (not $octet{'}'}) { |
9070
|
|
|
|
|
|
|
$delimiter = '{'; |
9071
|
|
|
|
|
|
|
$end_delimiter = '}'; |
9072
|
0
|
|
|
|
|
0
|
} |
9073
|
0
|
|
|
|
|
0
|
elsif (not $octet{']'}) { |
9074
|
|
|
|
|
|
|
$delimiter = '['; |
9075
|
|
|
|
|
|
|
$end_delimiter = ']'; |
9076
|
0
|
|
|
|
|
0
|
} |
9077
|
0
|
|
|
|
|
0
|
elsif (not $octet{'>'}) { |
9078
|
|
|
|
|
|
|
$delimiter = '<'; |
9079
|
|
|
|
|
|
|
$end_delimiter = '>'; |
9080
|
0
|
|
|
|
|
0
|
} |
9081
|
0
|
0
|
|
|
|
0
|
else { |
9082
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9083
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9084
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
9085
|
|
|
|
|
|
|
$end_delimiter = $char; |
9086
|
|
|
|
|
|
|
last; |
9087
|
|
|
|
|
|
|
} |
9088
|
|
|
|
|
|
|
} |
9089
|
|
|
|
|
|
|
} |
9090
|
0
|
|
|
|
|
0
|
} |
9091
|
1587
|
|
|
|
|
2535
|
|
9092
|
1587
|
|
|
|
|
2235
|
my $left_e = 0; |
9093
|
|
|
|
|
|
|
my $right_e = 0; |
9094
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9095
|
1587
|
50
|
66
|
|
|
4234
|
|
|
|
50
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
9096
|
5422
|
|
|
|
|
28986
|
# "\L\u" --> "\u\L" |
9097
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
9098
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9099
|
|
|
|
|
|
|
} |
9100
|
|
|
|
|
|
|
|
9101
|
0
|
|
|
|
|
0
|
# "\U\l" --> "\l\U" |
9102
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
9103
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9104
|
|
|
|
|
|
|
} |
9105
|
|
|
|
|
|
|
|
9106
|
0
|
|
|
|
|
0
|
# octal escape sequence |
9107
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
9108
|
|
|
|
|
|
|
$char[$i] = Ehp15::octchr($1); |
9109
|
|
|
|
|
|
|
} |
9110
|
|
|
|
|
|
|
|
9111
|
1
|
|
|
|
|
3
|
# hexadecimal escape sequence |
9112
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
9113
|
|
|
|
|
|
|
$char[$i] = Ehp15::hexchr($1); |
9114
|
|
|
|
|
|
|
} |
9115
|
|
|
|
|
|
|
|
9116
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
9117
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
9118
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
9119
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
9120
|
1
|
|
|
|
|
4
|
# \P{PROPERTY} --> P\{PROPERTY} |
9121
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} ) \z/oxms) { |
9122
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9123
|
|
|
|
|
|
|
} |
9124
|
|
|
|
|
|
|
|
9125
|
6
|
|
|
|
|
19
|
# \p, \P, \X --> p, P, X |
9126
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
9127
|
|
|
|
|
|
|
$char[$i] = $1; |
9128
|
4
|
100
|
100
|
|
|
10
|
} |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
9129
|
|
|
|
|
|
|
|
9130
|
|
|
|
|
|
|
if (0) { |
9131
|
|
|
|
|
|
|
} |
9132
|
5422
|
|
|
|
|
36898
|
|
9133
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
9134
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
9135
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9136
|
|
|
|
|
|
|
} |
9137
|
|
|
|
|
|
|
|
9138
|
77
|
50
|
33
|
|
|
393
|
# join separated multiple-octet |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
9139
|
6
|
|
|
|
|
164
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
9140
|
|
|
|
|
|
|
if ( ($i+3 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+3]) == 3) and (CORE::eval(sprintf '"%s%s%s%s"', @char[$i..$i+3]) =~ /\A $q_char \z/oxms)) { |
9141
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 3; |
9142
|
0
|
|
|
|
|
0
|
} |
9143
|
|
|
|
|
|
|
elsif (($i+2 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+2]) == 2) and (CORE::eval(sprintf '"%s%s%s"', @char[$i..$i+2]) =~ /\A $q_char \z/oxms)) { |
9144
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 2; |
9145
|
0
|
|
|
|
|
0
|
} |
9146
|
|
|
|
|
|
|
elsif (($i+1 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, $char[$i+1 ]) == 1) and (CORE::eval(sprintf '"%s%s"', @char[$i..$i+1]) =~ /\A $q_char \z/oxms)) { |
9147
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
9148
|
|
|
|
|
|
|
} |
9149
|
|
|
|
|
|
|
} |
9150
|
|
|
|
|
|
|
|
9151
|
0
|
|
|
|
|
0
|
# open character class [...] |
9152
|
|
|
|
|
|
|
elsif ($char[$i] eq '[') { |
9153
|
|
|
|
|
|
|
my $left = $i; |
9154
|
|
|
|
|
|
|
|
9155
|
|
|
|
|
|
|
# [] make die "Unmatched [] in regexp ...\n" |
9156
|
586
|
100
|
|
|
|
1024
|
# (and so on) |
9157
|
586
|
|
|
|
|
1513
|
|
9158
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9159
|
|
|
|
|
|
|
$i++; |
9160
|
3
|
|
|
|
|
8
|
} |
9161
|
586
|
50
|
|
|
|
753
|
|
9162
|
2583
|
|
|
|
|
4111
|
while (1) { |
9163
|
|
|
|
|
|
|
if (++$i > $#char) { |
9164
|
0
|
100
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9165
|
2583
|
|
|
|
|
4368
|
} |
9166
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9167
|
|
|
|
|
|
|
my $right = $i; |
9168
|
586
|
100
|
|
|
|
730
|
|
9169
|
586
|
|
|
|
|
3117
|
# [...] |
|
90
|
|
|
|
|
239
|
|
9170
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9171
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Ehp15::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
9172
|
270
|
|
|
|
|
466
|
} |
9173
|
|
|
|
|
|
|
else { |
9174
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Ehp15::charlist_qr(@char[$left+1..$right-1], $modifier); |
9175
|
496
|
|
|
|
|
2027
|
} |
9176
|
586
|
|
|
|
|
1229
|
|
9177
|
|
|
|
|
|
|
$i = $left; |
9178
|
|
|
|
|
|
|
last; |
9179
|
|
|
|
|
|
|
} |
9180
|
|
|
|
|
|
|
} |
9181
|
|
|
|
|
|
|
} |
9182
|
|
|
|
|
|
|
|
9183
|
586
|
|
|
|
|
1813
|
# open character class [^...] |
9184
|
|
|
|
|
|
|
elsif ($char[$i] eq '[^') { |
9185
|
|
|
|
|
|
|
my $left = $i; |
9186
|
|
|
|
|
|
|
|
9187
|
|
|
|
|
|
|
# [^] make die "Unmatched [] in regexp ...\n" |
9188
|
328
|
100
|
|
|
|
530
|
# (and so on) |
9189
|
328
|
|
|
|
|
781
|
|
9190
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9191
|
|
|
|
|
|
|
$i++; |
9192
|
5
|
|
|
|
|
8
|
} |
9193
|
328
|
50
|
|
|
|
428
|
|
9194
|
1447
|
|
|
|
|
2222
|
while (1) { |
9195
|
|
|
|
|
|
|
if (++$i > $#char) { |
9196
|
0
|
100
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9197
|
1447
|
|
|
|
|
2431
|
} |
9198
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9199
|
|
|
|
|
|
|
my $right = $i; |
9200
|
328
|
100
|
|
|
|
403
|
|
9201
|
328
|
|
|
|
|
1665
|
# [^...] |
|
90
|
|
|
|
|
208
|
|
9202
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9203
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Ehp15::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
9204
|
270
|
|
|
|
|
443
|
} |
9205
|
|
|
|
|
|
|
else { |
9206
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Ehp15::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
9207
|
238
|
|
|
|
|
855
|
} |
9208
|
328
|
|
|
|
|
663
|
|
9209
|
|
|
|
|
|
|
$i = $left; |
9210
|
|
|
|
|
|
|
last; |
9211
|
|
|
|
|
|
|
} |
9212
|
|
|
|
|
|
|
} |
9213
|
|
|
|
|
|
|
} |
9214
|
|
|
|
|
|
|
|
9215
|
328
|
|
|
|
|
960
|
# rewrite character class or escape character |
9216
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
9217
|
|
|
|
|
|
|
$char[$i] = $char; |
9218
|
|
|
|
|
|
|
} |
9219
|
|
|
|
|
|
|
|
9220
|
215
|
50
|
|
|
|
561
|
# /i modifier |
9221
|
238
|
|
|
|
|
437
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ehp15::uc($char[$i]) ne Ehp15::fc($char[$i]))) { |
9222
|
|
|
|
|
|
|
if (CORE::length(Ehp15::fc($char[$i])) == 1) { |
9223
|
|
|
|
|
|
|
$char[$i] = '[' . Ehp15::uc($char[$i]) . Ehp15::fc($char[$i]) . ']'; |
9224
|
238
|
|
|
|
|
425
|
} |
9225
|
|
|
|
|
|
|
else { |
9226
|
|
|
|
|
|
|
$char[$i] = '(?:' . Ehp15::uc($char[$i]) . '|' . Ehp15::fc($char[$i]) . ')'; |
9227
|
|
|
|
|
|
|
} |
9228
|
|
|
|
|
|
|
} |
9229
|
|
|
|
|
|
|
|
9230
|
0
|
50
|
|
|
|
0
|
# \u \l \U \L \F \Q \E |
9231
|
1
|
|
|
|
|
5
|
elsif ($char[$i] =~ /\A [<>] \z/oxms) { |
9232
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9233
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9234
|
|
|
|
|
|
|
} |
9235
|
0
|
|
|
|
|
0
|
} |
9236
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\u') { |
9237
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ucfirst qq<'; |
9238
|
|
|
|
|
|
|
$left_e++; |
9239
|
0
|
|
|
|
|
0
|
} |
9240
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\l') { |
9241
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::lcfirst qq<'; |
9242
|
|
|
|
|
|
|
$left_e++; |
9243
|
0
|
|
|
|
|
0
|
} |
9244
|
1
|
|
|
|
|
2
|
elsif ($char[$i] eq '\U') { |
9245
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::uc qq<'; |
9246
|
|
|
|
|
|
|
$left_e++; |
9247
|
1
|
|
|
|
|
4
|
} |
9248
|
1
|
|
|
|
|
3
|
elsif ($char[$i] eq '\L') { |
9249
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::lc qq<'; |
9250
|
|
|
|
|
|
|
$left_e++; |
9251
|
1
|
|
|
|
|
3
|
} |
9252
|
9
|
|
|
|
|
16
|
elsif ($char[$i] eq '\F') { |
9253
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::fc qq<'; |
9254
|
|
|
|
|
|
|
$left_e++; |
9255
|
9
|
|
|
|
|
22
|
} |
9256
|
22
|
|
|
|
|
54
|
elsif ($char[$i] eq '\Q') { |
9257
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
9258
|
|
|
|
|
|
|
$left_e++; |
9259
|
22
|
50
|
|
|
|
59
|
} |
9260
|
33
|
|
|
|
|
80
|
elsif ($char[$i] eq '\E') { |
9261
|
33
|
|
|
|
|
53
|
if ($right_e < $left_e) { |
9262
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
9263
|
|
|
|
|
|
|
$right_e++; |
9264
|
33
|
|
|
|
|
83
|
} |
9265
|
|
|
|
|
|
|
else { |
9266
|
|
|
|
|
|
|
$char[$i] = ''; |
9267
|
|
|
|
|
|
|
} |
9268
|
0
|
|
|
|
|
0
|
} |
9269
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
9270
|
0
|
|
|
|
|
0
|
while (1) { |
9271
|
|
|
|
|
|
|
if (++$i > $#char) { |
9272
|
0
|
0
|
|
|
|
0
|
last; |
9273
|
0
|
|
|
|
|
0
|
} |
9274
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
9275
|
|
|
|
|
|
|
last; |
9276
|
|
|
|
|
|
|
} |
9277
|
|
|
|
|
|
|
} |
9278
|
|
|
|
|
|
|
} |
9279
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
9280
|
|
|
|
|
|
|
} |
9281
|
|
|
|
|
|
|
|
9282
|
0
|
0
|
|
|
|
0
|
# $0 --> $0 |
9283
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
9284
|
|
|
|
|
|
|
if ($ignorecase) { |
9285
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9286
|
|
|
|
|
|
|
} |
9287
|
0
|
0
|
|
|
|
0
|
} |
9288
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
9289
|
|
|
|
|
|
|
if ($ignorecase) { |
9290
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9291
|
|
|
|
|
|
|
} |
9292
|
|
|
|
|
|
|
} |
9293
|
|
|
|
|
|
|
|
9294
|
|
|
|
|
|
|
# $$ --> $$ |
9295
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
9296
|
|
|
|
|
|
|
} |
9297
|
|
|
|
|
|
|
|
9298
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
9299
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
9300
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
9301
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
9302
|
|
|
|
|
|
|
if ($ignorecase) { |
9303
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9304
|
|
|
|
|
|
|
} |
9305
|
0
|
|
|
|
|
0
|
} |
9306
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9307
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
9308
|
|
|
|
|
|
|
if ($ignorecase) { |
9309
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9310
|
|
|
|
|
|
|
} |
9311
|
|
|
|
|
|
|
} |
9312
|
|
|
|
|
|
|
|
9313
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
9314
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
9315
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
9316
|
|
|
|
|
|
|
if ($ignorecase) { |
9317
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9318
|
|
|
|
|
|
|
} |
9319
|
|
|
|
|
|
|
} |
9320
|
|
|
|
|
|
|
|
9321
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
9322
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
9323
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
9324
|
|
|
|
|
|
|
if ($ignorecase) { |
9325
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9326
|
|
|
|
|
|
|
} |
9327
|
|
|
|
|
|
|
} |
9328
|
|
|
|
|
|
|
|
9329
|
0
|
|
|
|
|
0
|
# $$foo |
9330
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
9331
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
9332
|
|
|
|
|
|
|
if ($ignorecase) { |
9333
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9334
|
|
|
|
|
|
|
} |
9335
|
|
|
|
|
|
|
} |
9336
|
|
|
|
|
|
|
|
9337
|
0
|
50
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ehp15::PREMATCH() |
9338
|
8
|
|
|
|
|
22
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
9339
|
|
|
|
|
|
|
if ($ignorecase) { |
9340
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(Ehp15::PREMATCH())]}'; |
9341
|
0
|
|
|
|
|
0
|
} |
9342
|
|
|
|
|
|
|
else { |
9343
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::PREMATCH()]}'; |
9344
|
|
|
|
|
|
|
} |
9345
|
|
|
|
|
|
|
} |
9346
|
|
|
|
|
|
|
|
9347
|
8
|
50
|
|
|
|
23
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ehp15::MATCH() |
9348
|
8
|
|
|
|
|
21
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
9349
|
|
|
|
|
|
|
if ($ignorecase) { |
9350
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(Ehp15::MATCH())]}'; |
9351
|
0
|
|
|
|
|
0
|
} |
9352
|
|
|
|
|
|
|
else { |
9353
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::MATCH()]}'; |
9354
|
|
|
|
|
|
|
} |
9355
|
|
|
|
|
|
|
} |
9356
|
|
|
|
|
|
|
|
9357
|
8
|
50
|
|
|
|
25
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ehp15::POSTMATCH() |
9358
|
6
|
|
|
|
|
19
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
9359
|
|
|
|
|
|
|
if ($ignorecase) { |
9360
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(Ehp15::POSTMATCH())]}'; |
9361
|
0
|
|
|
|
|
0
|
} |
9362
|
|
|
|
|
|
|
else { |
9363
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::POSTMATCH()]}'; |
9364
|
|
|
|
|
|
|
} |
9365
|
|
|
|
|
|
|
} |
9366
|
|
|
|
|
|
|
|
9367
|
6
|
0
|
|
|
|
22
|
# ${ foo } |
9368
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
9369
|
|
|
|
|
|
|
if ($ignorecase) { |
9370
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9371
|
|
|
|
|
|
|
} |
9372
|
|
|
|
|
|
|
} |
9373
|
|
|
|
|
|
|
|
9374
|
0
|
|
|
|
|
0
|
# ${ ... } |
9375
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
9376
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
9377
|
|
|
|
|
|
|
if ($ignorecase) { |
9378
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9379
|
|
|
|
|
|
|
} |
9380
|
|
|
|
|
|
|
} |
9381
|
|
|
|
|
|
|
|
9382
|
0
|
|
|
|
|
0
|
# $scalar or @array |
9383
|
31
|
100
|
|
|
|
146
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
9384
|
31
|
|
|
|
|
129
|
$char[$i] = e_string($char[$i]); |
9385
|
|
|
|
|
|
|
if ($ignorecase) { |
9386
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9387
|
|
|
|
|
|
|
} |
9388
|
|
|
|
|
|
|
} |
9389
|
|
|
|
|
|
|
|
9390
|
4
|
100
|
66
|
|
|
17
|
# quote character before ? + * { |
|
|
50
|
|
|
|
|
|
9391
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
9392
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
9393
|
188
|
|
|
|
|
1546
|
} |
9394
|
0
|
0
|
|
|
|
0
|
elsif (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9395
|
0
|
|
|
|
|
0
|
my $char = $char[$i-1]; |
9396
|
|
|
|
|
|
|
if ($char[$i] eq '{') { |
9397
|
|
|
|
|
|
|
die __FILE__, qq{: "MULTIBYTE{n}" should be "(MULTIBYTE){n}" in m?? (and shift \$1,\$2,\$3,...) ($char){n}\n}; |
9398
|
0
|
|
|
|
|
0
|
} |
9399
|
|
|
|
|
|
|
else { |
9400
|
|
|
|
|
|
|
die __FILE__, qq{: "MULTIBYTE$char[$i]" should be "(MULTIBYTE)$char[$i]" in m?? (and shift \$1,\$2,\$3,...) ($char)$char[$i]\n}; |
9401
|
|
|
|
|
|
|
} |
9402
|
0
|
|
|
|
|
0
|
} |
9403
|
|
|
|
|
|
|
else { |
9404
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
9405
|
|
|
|
|
|
|
} |
9406
|
|
|
|
|
|
|
} |
9407
|
|
|
|
|
|
|
} |
9408
|
187
|
|
|
|
|
823
|
|
9409
|
1587
|
50
|
|
|
|
3047
|
# make regexp string |
9410
|
1587
|
0
|
0
|
|
|
3504
|
$modifier =~ tr/i//d; |
9411
|
0
|
|
|
|
|
0
|
if ($left_e > $right_e) { |
9412
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9413
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, @char, '>]}' x ($left_e - $right_e), $matched, $end_delimiter, $modifier; |
9414
|
0
|
|
|
|
|
0
|
} |
9415
|
|
|
|
|
|
|
else { |
9416
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier; |
9417
|
0
|
100
|
100
|
|
|
0
|
} |
9418
|
1587
|
|
|
|
|
8644
|
} |
9419
|
|
|
|
|
|
|
if (($ope =~ /\A m? \z/oxms) and ($delimiter eq '?')) { |
9420
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, @char, $matched, $end_delimiter, $modifier; |
9421
|
94
|
|
|
|
|
723
|
} |
9422
|
|
|
|
|
|
|
else { |
9423
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9424
|
|
|
|
|
|
|
} |
9425
|
|
|
|
|
|
|
} |
9426
|
|
|
|
|
|
|
|
9427
|
|
|
|
|
|
|
# |
9428
|
|
|
|
|
|
|
# double quote stuff |
9429
|
1493
|
|
|
540
|
0
|
13826
|
# |
9430
|
|
|
|
|
|
|
sub qq_stuff { |
9431
|
|
|
|
|
|
|
my($delimiter,$end_delimiter,$stuff) = @_; |
9432
|
540
|
100
|
|
|
|
1053
|
|
9433
|
540
|
|
|
|
|
1364
|
# scalar variable or array variable |
9434
|
|
|
|
|
|
|
if ($stuff =~ /\A [\$\@] /oxms) { |
9435
|
|
|
|
|
|
|
return $stuff; |
9436
|
|
|
|
|
|
|
} |
9437
|
300
|
|
|
|
|
1146
|
|
|
240
|
|
|
|
|
724
|
|
9438
|
280
|
|
|
|
|
1066
|
# quote by delimiter |
9439
|
240
|
50
|
|
|
|
625
|
my %octet = map {$_ => 1} ($stuff =~ /\G ([\x00-\xFF]) /oxmsg); |
9440
|
240
|
50
|
|
|
|
423
|
for my $char (qw( ! " $ % & * + - . / : = ? @ ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9441
|
240
|
50
|
|
|
|
410
|
next if $char eq $delimiter; |
9442
|
240
|
|
|
|
|
435
|
next if $char eq $end_delimiter; |
9443
|
|
|
|
|
|
|
if (not $octet{$char}) { |
9444
|
|
|
|
|
|
|
return join '', 'qq', $char, $stuff, $char; |
9445
|
240
|
|
|
|
|
1016
|
} |
9446
|
|
|
|
|
|
|
} |
9447
|
|
|
|
|
|
|
return join '', 'qq', '<', $stuff, '>'; |
9448
|
|
|
|
|
|
|
} |
9449
|
|
|
|
|
|
|
|
9450
|
|
|
|
|
|
|
# |
9451
|
|
|
|
|
|
|
# escape regexp (m'', qr'', and m''b, qr''b) |
9452
|
0
|
|
|
163
|
0
|
0
|
# |
9453
|
163
|
|
100
|
|
|
812
|
sub e_qr_q { |
9454
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9455
|
163
|
|
|
|
|
503
|
$modifier ||= ''; |
9456
|
163
|
50
|
|
|
|
281
|
|
9457
|
163
|
|
|
|
|
501
|
$modifier =~ tr/p//d; |
9458
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
9459
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
9460
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
9461
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
9462
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
9463
|
|
|
|
|
|
|
last; |
9464
|
0
|
|
|
|
|
0
|
} |
9465
|
|
|
|
|
|
|
} |
9466
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
9467
|
0
|
|
|
|
|
0
|
} |
9468
|
|
|
|
|
|
|
|
9469
|
|
|
|
|
|
|
$slash = 'div'; |
9470
|
163
|
100
|
|
|
|
272
|
|
|
|
100
|
|
|
|
|
|
9471
|
163
|
|
|
|
|
464
|
# literal null string pattern |
9472
|
8
|
|
|
|
|
12
|
if ($string eq '') { |
9473
|
8
|
|
|
|
|
11
|
$modifier =~ tr/bB//d; |
9474
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9475
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
9476
|
|
|
|
|
|
|
} |
9477
|
|
|
|
|
|
|
|
9478
|
8
|
|
|
|
|
38
|
# with /b /B modifier |
9479
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
9480
|
|
|
|
|
|
|
return e_qr_qb($ope,$delimiter,$end_delimiter,$string,$modifier); |
9481
|
|
|
|
|
|
|
} |
9482
|
|
|
|
|
|
|
|
9483
|
89
|
|
|
|
|
222
|
# without /b /B modifier |
9484
|
|
|
|
|
|
|
else { |
9485
|
|
|
|
|
|
|
return e_qr_qt($ope,$delimiter,$end_delimiter,$string,$modifier); |
9486
|
|
|
|
|
|
|
} |
9487
|
|
|
|
|
|
|
} |
9488
|
|
|
|
|
|
|
|
9489
|
|
|
|
|
|
|
# |
9490
|
|
|
|
|
|
|
# escape regexp (m'', qr'') |
9491
|
66
|
|
|
66
|
0
|
176
|
# |
9492
|
|
|
|
|
|
|
sub e_qr_qt { |
9493
|
66
|
100
|
|
|
|
179
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9494
|
|
|
|
|
|
|
|
9495
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
9496
|
66
|
|
|
|
|
169
|
|
9497
|
|
|
|
|
|
|
# split regexp |
9498
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9499
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\[\$\@\/] | |
9500
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
9501
|
|
|
|
|
|
|
\[\^ | |
9502
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
9503
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
9504
|
|
|
|
|
|
|
[\$\@\/] | |
9505
|
|
|
|
|
|
|
\\ (?:$q_char) | |
9506
|
|
|
|
|
|
|
(?:$q_char) |
9507
|
|
|
|
|
|
|
))/oxmsg; |
9508
|
66
|
|
|
|
|
717
|
|
9509
|
66
|
100
|
100
|
|
|
257
|
# unescape character |
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
9510
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9511
|
|
|
|
|
|
|
if (0) { |
9512
|
|
|
|
|
|
|
} |
9513
|
79
|
|
|
|
|
882
|
|
9514
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
9515
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
9516
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9517
|
|
|
|
|
|
|
} |
9518
|
|
|
|
|
|
|
|
9519
|
2
|
|
|
|
|
14
|
# open character class [...] |
9520
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
9521
|
0
|
|
|
|
|
0
|
my $left = $i; |
9522
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9523
|
0
|
|
|
|
|
0
|
$i++; |
9524
|
0
|
0
|
|
|
|
0
|
} |
9525
|
0
|
|
|
|
|
0
|
while (1) { |
9526
|
|
|
|
|
|
|
if (++$i > $#char) { |
9527
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9528
|
0
|
|
|
|
|
0
|
} |
9529
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9530
|
|
|
|
|
|
|
my $right = $i; |
9531
|
0
|
|
|
|
|
0
|
|
9532
|
|
|
|
|
|
|
# [...] |
9533
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Ehp15::charlist_qr(@char[$left+1..$right-1], $modifier); |
9534
|
0
|
|
|
|
|
0
|
|
9535
|
|
|
|
|
|
|
$i = $left; |
9536
|
|
|
|
|
|
|
last; |
9537
|
|
|
|
|
|
|
} |
9538
|
|
|
|
|
|
|
} |
9539
|
|
|
|
|
|
|
} |
9540
|
|
|
|
|
|
|
|
9541
|
0
|
|
|
|
|
0
|
# open character class [^...] |
9542
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
9543
|
0
|
|
|
|
|
0
|
my $left = $i; |
9544
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9545
|
0
|
|
|
|
|
0
|
$i++; |
9546
|
0
|
0
|
|
|
|
0
|
} |
9547
|
0
|
|
|
|
|
0
|
while (1) { |
9548
|
|
|
|
|
|
|
if (++$i > $#char) { |
9549
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9550
|
0
|
|
|
|
|
0
|
} |
9551
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9552
|
|
|
|
|
|
|
my $right = $i; |
9553
|
0
|
|
|
|
|
0
|
|
9554
|
|
|
|
|
|
|
# [^...] |
9555
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Ehp15::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
9556
|
0
|
|
|
|
|
0
|
|
9557
|
|
|
|
|
|
|
$i = $left; |
9558
|
|
|
|
|
|
|
last; |
9559
|
|
|
|
|
|
|
} |
9560
|
|
|
|
|
|
|
} |
9561
|
|
|
|
|
|
|
} |
9562
|
|
|
|
|
|
|
|
9563
|
0
|
|
|
|
|
0
|
# escape $ @ / and \ |
9564
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
9565
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9566
|
|
|
|
|
|
|
} |
9567
|
|
|
|
|
|
|
|
9568
|
0
|
|
|
|
|
0
|
# rewrite character class or escape character |
9569
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
9570
|
|
|
|
|
|
|
$char[$i] = $char; |
9571
|
|
|
|
|
|
|
} |
9572
|
|
|
|
|
|
|
|
9573
|
0
|
50
|
|
|
|
0
|
# /i modifier |
9574
|
16
|
|
|
|
|
41
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ehp15::uc($char[$i]) ne Ehp15::fc($char[$i]))) { |
9575
|
|
|
|
|
|
|
if (CORE::length(Ehp15::fc($char[$i])) == 1) { |
9576
|
|
|
|
|
|
|
$char[$i] = '[' . Ehp15::uc($char[$i]) . Ehp15::fc($char[$i]) . ']'; |
9577
|
16
|
|
|
|
|
40
|
} |
9578
|
|
|
|
|
|
|
else { |
9579
|
|
|
|
|
|
|
$char[$i] = '(?:' . Ehp15::uc($char[$i]) . '|' . Ehp15::fc($char[$i]) . ')'; |
9580
|
|
|
|
|
|
|
} |
9581
|
|
|
|
|
|
|
} |
9582
|
|
|
|
|
|
|
|
9583
|
0
|
0
|
|
|
|
0
|
# quote character before ? + * { |
9584
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
9585
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
9586
|
0
|
|
|
|
|
0
|
} |
9587
|
|
|
|
|
|
|
else { |
9588
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
9589
|
|
|
|
|
|
|
} |
9590
|
|
|
|
|
|
|
} |
9591
|
0
|
|
|
|
|
0
|
} |
9592
|
66
|
|
|
|
|
145
|
|
9593
|
|
|
|
|
|
|
$delimiter = '/'; |
9594
|
66
|
|
|
|
|
112
|
$end_delimiter = '/'; |
9595
|
66
|
|
|
|
|
100
|
|
9596
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9597
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $anchor, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9598
|
|
|
|
|
|
|
} |
9599
|
|
|
|
|
|
|
|
9600
|
|
|
|
|
|
|
# |
9601
|
|
|
|
|
|
|
# escape regexp (m''b, qr''b) |
9602
|
66
|
|
|
89
|
0
|
435
|
# |
9603
|
|
|
|
|
|
|
sub e_qr_qb { |
9604
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9605
|
89
|
|
|
|
|
226
|
|
9606
|
|
|
|
|
|
|
# split regexp |
9607
|
|
|
|
|
|
|
my @char = $string =~ /\G ((?>[^\\]|\\\\|[\x00-\xFF])) /oxmsg; |
9608
|
89
|
|
|
|
|
373
|
|
9609
|
89
|
50
|
|
|
|
246
|
# unescape character |
|
|
50
|
|
|
|
|
|
9610
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9611
|
|
|
|
|
|
|
if (0) { |
9612
|
|
|
|
|
|
|
} |
9613
|
199
|
|
|
|
|
670
|
|
9614
|
|
|
|
|
|
|
# remain \\ |
9615
|
|
|
|
|
|
|
elsif ($char[$i] eq '\\\\') { |
9616
|
|
|
|
|
|
|
} |
9617
|
|
|
|
|
|
|
|
9618
|
0
|
|
|
|
|
0
|
# escape $ @ / and \ |
9619
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
9620
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9621
|
|
|
|
|
|
|
} |
9622
|
0
|
|
|
|
|
0
|
} |
9623
|
89
|
|
|
|
|
143
|
|
9624
|
89
|
|
|
|
|
115
|
$delimiter = '/'; |
9625
|
|
|
|
|
|
|
$end_delimiter = '/'; |
9626
|
|
|
|
|
|
|
return join '', $ope, $delimiter, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
9627
|
|
|
|
|
|
|
} |
9628
|
|
|
|
|
|
|
|
9629
|
|
|
|
|
|
|
# |
9630
|
|
|
|
|
|
|
# escape regexp (s/here//) |
9631
|
89
|
|
|
194
|
0
|
541
|
# |
9632
|
194
|
|
100
|
|
|
653
|
sub e_s1 { |
9633
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
9634
|
194
|
|
|
|
|
743
|
$modifier ||= ''; |
9635
|
194
|
50
|
|
|
|
361
|
|
9636
|
194
|
|
|
|
|
805
|
$modifier =~ tr/p//d; |
9637
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
9638
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
9639
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
9640
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
9641
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
9642
|
|
|
|
|
|
|
last; |
9643
|
0
|
|
|
|
|
0
|
} |
9644
|
|
|
|
|
|
|
} |
9645
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
9646
|
0
|
|
|
|
|
0
|
} |
9647
|
|
|
|
|
|
|
|
9648
|
|
|
|
|
|
|
$slash = 'div'; |
9649
|
194
|
100
|
|
|
|
392
|
|
|
|
100
|
|
|
|
|
|
9650
|
194
|
|
|
|
|
813
|
# literal null string pattern |
9651
|
8
|
|
|
|
|
9
|
if ($string eq '') { |
9652
|
8
|
|
|
|
|
10
|
$modifier =~ tr/bB//d; |
9653
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
9654
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
9655
|
|
|
|
|
|
|
} |
9656
|
|
|
|
|
|
|
|
9657
|
|
|
|
|
|
|
# /b /B modifier |
9658
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
9659
|
8
|
50
|
|
|
|
57
|
|
9660
|
44
|
|
|
|
|
474
|
# choice again delimiter |
9661
|
0
|
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
0
|
|
|
|
|
0
|
|
9662
|
0
|
0
|
|
|
|
0
|
my @char = $string =~ /\G ([\x00-\xFF]) /oxmsg; |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9663
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9664
|
0
|
|
|
|
|
0
|
if (not $octet{')'}) { |
9665
|
|
|
|
|
|
|
$delimiter = '('; |
9666
|
|
|
|
|
|
|
$end_delimiter = ')'; |
9667
|
0
|
|
|
|
|
0
|
} |
9668
|
0
|
|
|
|
|
0
|
elsif (not $octet{'}'}) { |
9669
|
|
|
|
|
|
|
$delimiter = '{'; |
9670
|
|
|
|
|
|
|
$end_delimiter = '}'; |
9671
|
0
|
|
|
|
|
0
|
} |
9672
|
0
|
|
|
|
|
0
|
elsif (not $octet{']'}) { |
9673
|
|
|
|
|
|
|
$delimiter = '['; |
9674
|
|
|
|
|
|
|
$end_delimiter = ']'; |
9675
|
0
|
|
|
|
|
0
|
} |
9676
|
0
|
|
|
|
|
0
|
elsif (not $octet{'>'}) { |
9677
|
|
|
|
|
|
|
$delimiter = '<'; |
9678
|
|
|
|
|
|
|
$end_delimiter = '>'; |
9679
|
0
|
|
|
|
|
0
|
} |
9680
|
0
|
0
|
|
|
|
0
|
else { |
9681
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9682
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9683
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
9684
|
|
|
|
|
|
|
$end_delimiter = $char; |
9685
|
|
|
|
|
|
|
last; |
9686
|
|
|
|
|
|
|
} |
9687
|
|
|
|
|
|
|
} |
9688
|
|
|
|
|
|
|
} |
9689
|
0
|
|
|
|
|
0
|
} |
9690
|
44
|
|
|
|
|
80
|
|
9691
|
44
|
|
|
|
|
66
|
my $prematch = ''; |
9692
|
|
|
|
|
|
|
$prematch = q{(\G[\x00-\xFF]*?)}; |
9693
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', $string, ')', $matched, $end_delimiter, $modifier; |
9694
|
44
|
100
|
|
|
|
361
|
} |
9695
|
142
|
|
|
|
|
551
|
|
9696
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
9697
|
|
|
|
|
|
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
9698
|
142
|
|
|
|
|
634
|
|
9699
|
|
|
|
|
|
|
# split regexp |
9700
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
9701
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\$\@\[\(]|[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
9702
|
|
|
|
|
|
|
\\ (?>[1-9][0-9]*) | |
9703
|
|
|
|
|
|
|
\\g (?>\s*) (?>[1-9][0-9]*) | |
9704
|
|
|
|
|
|
|
\\g (?>\s*) \{ (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} | |
9705
|
|
|
|
|
|
|
\\g (?>\s*) \{ (?>\s*) - (?>\s*) (?>[1-9][0-9]*) (?>\s*) \} | |
9706
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
9707
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
9708
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
9709
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
9710
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
9711
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} | |
9712
|
|
|
|
|
|
|
\\ $q_char | |
9713
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
9714
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
9715
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
9716
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
9717
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
9718
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
9719
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
9720
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
9721
|
|
|
|
|
|
|
\[\^ | |
9722
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
9723
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
9724
|
|
|
|
|
|
|
\(\? | |
9725
|
|
|
|
|
|
|
$q_char |
9726
|
|
|
|
|
|
|
))/oxmsg; |
9727
|
142
|
50
|
|
|
|
38488
|
|
9728
|
142
|
|
|
|
|
1176
|
# choice again delimiter |
|
0
|
|
|
|
|
0
|
|
9729
|
0
|
0
|
|
|
|
0
|
if ($delimiter =~ / [\@:] /oxms) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
9730
|
0
|
|
|
|
|
0
|
my %octet = map {$_ => 1} @char; |
9731
|
0
|
|
|
|
|
0
|
if (not $octet{')'}) { |
9732
|
|
|
|
|
|
|
$delimiter = '('; |
9733
|
|
|
|
|
|
|
$end_delimiter = ')'; |
9734
|
0
|
|
|
|
|
0
|
} |
9735
|
0
|
|
|
|
|
0
|
elsif (not $octet{'}'}) { |
9736
|
|
|
|
|
|
|
$delimiter = '{'; |
9737
|
|
|
|
|
|
|
$end_delimiter = '}'; |
9738
|
0
|
|
|
|
|
0
|
} |
9739
|
0
|
|
|
|
|
0
|
elsif (not $octet{']'}) { |
9740
|
|
|
|
|
|
|
$delimiter = '['; |
9741
|
|
|
|
|
|
|
$end_delimiter = ']'; |
9742
|
0
|
|
|
|
|
0
|
} |
9743
|
0
|
|
|
|
|
0
|
elsif (not $octet{'>'}) { |
9744
|
|
|
|
|
|
|
$delimiter = '<'; |
9745
|
|
|
|
|
|
|
$end_delimiter = '>'; |
9746
|
0
|
|
|
|
|
0
|
} |
9747
|
0
|
0
|
|
|
|
0
|
else { |
9748
|
0
|
|
|
|
|
0
|
for my $char (qw( ! " $ % & * + - . / = ? ^ ` | ~ ), "\x00".."\x1F", "\x7F", "\xFF") { |
9749
|
0
|
|
|
|
|
0
|
if (not $octet{$char}) { |
9750
|
0
|
|
|
|
|
0
|
$delimiter = $char; |
9751
|
|
|
|
|
|
|
$end_delimiter = $char; |
9752
|
|
|
|
|
|
|
last; |
9753
|
|
|
|
|
|
|
} |
9754
|
|
|
|
|
|
|
} |
9755
|
|
|
|
|
|
|
} |
9756
|
|
|
|
|
|
|
} |
9757
|
0
|
|
|
|
|
0
|
|
|
142
|
|
|
|
|
346
|
|
9758
|
|
|
|
|
|
|
# count '(' |
9759
|
476
|
|
|
|
|
905
|
my $parens = grep { $_ eq '(' } @char; |
9760
|
142
|
|
|
|
|
262
|
|
9761
|
142
|
|
|
|
|
238
|
my $left_e = 0; |
9762
|
|
|
|
|
|
|
my $right_e = 0; |
9763
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
9764
|
142
|
50
|
33
|
|
|
437
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
9765
|
397
|
|
|
|
|
2917
|
# "\L\u" --> "\u\L" |
9766
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
9767
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9768
|
|
|
|
|
|
|
} |
9769
|
|
|
|
|
|
|
|
9770
|
0
|
|
|
|
|
0
|
# "\U\l" --> "\l\U" |
9771
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
9772
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
9773
|
|
|
|
|
|
|
} |
9774
|
|
|
|
|
|
|
|
9775
|
0
|
|
|
|
|
0
|
# octal escape sequence |
9776
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
9777
|
|
|
|
|
|
|
$char[$i] = Ehp15::octchr($1); |
9778
|
|
|
|
|
|
|
} |
9779
|
|
|
|
|
|
|
|
9780
|
1
|
|
|
|
|
3
|
# hexadecimal escape sequence |
9781
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
9782
|
|
|
|
|
|
|
$char[$i] = Ehp15::hexchr($1); |
9783
|
|
|
|
|
|
|
} |
9784
|
|
|
|
|
|
|
|
9785
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
9786
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
9787
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
9788
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
9789
|
1
|
|
|
|
|
3
|
# \P{PROPERTY} --> P\{PROPERTY} |
9790
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} ) \z/oxms) { |
9791
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9792
|
|
|
|
|
|
|
} |
9793
|
|
|
|
|
|
|
|
9794
|
0
|
|
|
|
|
0
|
# \p, \P, \X --> p, P, X |
9795
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
9796
|
|
|
|
|
|
|
$char[$i] = $1; |
9797
|
0
|
100
|
100
|
|
|
0
|
} |
|
|
50
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
9798
|
|
|
|
|
|
|
|
9799
|
|
|
|
|
|
|
if (0) { |
9800
|
|
|
|
|
|
|
} |
9801
|
397
|
|
|
|
|
4576
|
|
9802
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
9803
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
9804
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
9805
|
|
|
|
|
|
|
} |
9806
|
|
|
|
|
|
|
|
9807
|
23
|
0
|
0
|
|
|
123
|
# join separated multiple-octet |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
9808
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
9809
|
|
|
|
|
|
|
if ( ($i+3 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+3]) == 3) and (CORE::eval(sprintf '"%s%s%s%s"', @char[$i..$i+3]) =~ /\A $q_char \z/oxms)) { |
9810
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 3; |
9811
|
0
|
|
|
|
|
0
|
} |
9812
|
|
|
|
|
|
|
elsif (($i+2 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+2]) == 2) and (CORE::eval(sprintf '"%s%s%s"', @char[$i..$i+2]) =~ /\A $q_char \z/oxms)) { |
9813
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 2; |
9814
|
0
|
|
|
|
|
0
|
} |
9815
|
|
|
|
|
|
|
elsif (($i+1 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, $char[$i+1 ]) == 1) and (CORE::eval(sprintf '"%s%s"', @char[$i..$i+1]) =~ /\A $q_char \z/oxms)) { |
9816
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
9817
|
|
|
|
|
|
|
} |
9818
|
|
|
|
|
|
|
} |
9819
|
|
|
|
|
|
|
|
9820
|
0
|
|
|
|
|
0
|
# open character class [...] |
9821
|
20
|
50
|
|
|
|
41
|
elsif ($char[$i] eq '[') { |
9822
|
20
|
|
|
|
|
74
|
my $left = $i; |
9823
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9824
|
0
|
|
|
|
|
0
|
$i++; |
9825
|
20
|
50
|
|
|
|
31
|
} |
9826
|
79
|
|
|
|
|
222
|
while (1) { |
9827
|
|
|
|
|
|
|
if (++$i > $#char) { |
9828
|
0
|
100
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9829
|
79
|
|
|
|
|
218
|
} |
9830
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9831
|
|
|
|
|
|
|
my $right = $i; |
9832
|
20
|
50
|
|
|
|
38
|
|
9833
|
20
|
|
|
|
|
161
|
# [...] |
|
0
|
|
|
|
|
0
|
|
9834
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9835
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Ehp15::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
9836
|
0
|
|
|
|
|
0
|
} |
9837
|
|
|
|
|
|
|
else { |
9838
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Ehp15::charlist_qr(@char[$left+1..$right-1], $modifier); |
9839
|
20
|
|
|
|
|
129
|
} |
9840
|
20
|
|
|
|
|
45
|
|
9841
|
|
|
|
|
|
|
$i = $left; |
9842
|
|
|
|
|
|
|
last; |
9843
|
|
|
|
|
|
|
} |
9844
|
|
|
|
|
|
|
} |
9845
|
|
|
|
|
|
|
} |
9846
|
|
|
|
|
|
|
|
9847
|
20
|
|
|
|
|
63
|
# open character class [^...] |
9848
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
9849
|
0
|
|
|
|
|
0
|
my $left = $i; |
9850
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
9851
|
0
|
|
|
|
|
0
|
$i++; |
9852
|
0
|
0
|
|
|
|
0
|
} |
9853
|
0
|
|
|
|
|
0
|
while (1) { |
9854
|
|
|
|
|
|
|
if (++$i > $#char) { |
9855
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
9856
|
0
|
|
|
|
|
0
|
} |
9857
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
9858
|
|
|
|
|
|
|
my $right = $i; |
9859
|
0
|
0
|
|
|
|
0
|
|
9860
|
0
|
|
|
|
|
0
|
# [^...] |
|
0
|
|
|
|
|
0
|
|
9861
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
9862
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Ehp15::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
9863
|
0
|
|
|
|
|
0
|
} |
9864
|
|
|
|
|
|
|
else { |
9865
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Ehp15::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
9866
|
0
|
|
|
|
|
0
|
} |
9867
|
0
|
|
|
|
|
0
|
|
9868
|
|
|
|
|
|
|
$i = $left; |
9869
|
|
|
|
|
|
|
last; |
9870
|
|
|
|
|
|
|
} |
9871
|
|
|
|
|
|
|
} |
9872
|
|
|
|
|
|
|
} |
9873
|
|
|
|
|
|
|
|
9874
|
0
|
|
|
|
|
0
|
# rewrite character class or escape character |
9875
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
9876
|
|
|
|
|
|
|
$char[$i] = $char; |
9877
|
|
|
|
|
|
|
} |
9878
|
|
|
|
|
|
|
|
9879
|
11
|
50
|
|
|
|
26
|
# /i modifier |
9880
|
11
|
|
|
|
|
25
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ehp15::uc($char[$i]) ne Ehp15::fc($char[$i]))) { |
9881
|
|
|
|
|
|
|
if (CORE::length(Ehp15::fc($char[$i])) == 1) { |
9882
|
|
|
|
|
|
|
$char[$i] = '[' . Ehp15::uc($char[$i]) . Ehp15::fc($char[$i]) . ']'; |
9883
|
11
|
|
|
|
|
27
|
} |
9884
|
|
|
|
|
|
|
else { |
9885
|
|
|
|
|
|
|
$char[$i] = '(?:' . Ehp15::uc($char[$i]) . '|' . Ehp15::fc($char[$i]) . ')'; |
9886
|
|
|
|
|
|
|
} |
9887
|
|
|
|
|
|
|
} |
9888
|
|
|
|
|
|
|
|
9889
|
0
|
50
|
|
|
|
0
|
# \u \l \U \L \F \Q \E |
9890
|
8
|
|
|
|
|
25
|
elsif ($char[$i] =~ /\A [<>] \z/oxms) { |
9891
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
9892
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
9893
|
|
|
|
|
|
|
} |
9894
|
0
|
|
|
|
|
0
|
} |
9895
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\u') { |
9896
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ucfirst qq<'; |
9897
|
|
|
|
|
|
|
$left_e++; |
9898
|
0
|
|
|
|
|
0
|
} |
9899
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\l') { |
9900
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::lcfirst qq<'; |
9901
|
|
|
|
|
|
|
$left_e++; |
9902
|
0
|
|
|
|
|
0
|
} |
9903
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\U') { |
9904
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::uc qq<'; |
9905
|
|
|
|
|
|
|
$left_e++; |
9906
|
0
|
|
|
|
|
0
|
} |
9907
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\L') { |
9908
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::lc qq<'; |
9909
|
|
|
|
|
|
|
$left_e++; |
9910
|
0
|
|
|
|
|
0
|
} |
9911
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\F') { |
9912
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::fc qq<'; |
9913
|
|
|
|
|
|
|
$left_e++; |
9914
|
0
|
|
|
|
|
0
|
} |
9915
|
7
|
|
|
|
|
14
|
elsif ($char[$i] eq '\Q') { |
9916
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
9917
|
|
|
|
|
|
|
$left_e++; |
9918
|
7
|
50
|
|
|
|
17
|
} |
9919
|
7
|
|
|
|
|
18
|
elsif ($char[$i] eq '\E') { |
9920
|
7
|
|
|
|
|
10
|
if ($right_e < $left_e) { |
9921
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
9922
|
|
|
|
|
|
|
$right_e++; |
9923
|
7
|
|
|
|
|
17
|
} |
9924
|
|
|
|
|
|
|
else { |
9925
|
|
|
|
|
|
|
$char[$i] = ''; |
9926
|
|
|
|
|
|
|
} |
9927
|
0
|
|
|
|
|
0
|
} |
9928
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
9929
|
0
|
|
|
|
|
0
|
while (1) { |
9930
|
|
|
|
|
|
|
if (++$i > $#char) { |
9931
|
0
|
0
|
|
|
|
0
|
last; |
9932
|
0
|
|
|
|
|
0
|
} |
9933
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
9934
|
|
|
|
|
|
|
last; |
9935
|
|
|
|
|
|
|
} |
9936
|
|
|
|
|
|
|
} |
9937
|
|
|
|
|
|
|
} |
9938
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
9939
|
|
|
|
|
|
|
} |
9940
|
|
|
|
|
|
|
|
9941
|
|
|
|
|
|
|
# \0 --> \0 |
9942
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ (?>\s*) 0 \z/oxms) { |
9943
|
|
|
|
|
|
|
} |
9944
|
|
|
|
|
|
|
|
9945
|
|
|
|
|
|
|
# \g{N}, \g{-N} |
9946
|
|
|
|
|
|
|
|
9947
|
|
|
|
|
|
|
# P.108 Using Simple Patterns |
9948
|
|
|
|
|
|
|
# in Chapter 7: In the World of Regular Expressions |
9949
|
|
|
|
|
|
|
# of ISBN 978-0-596-52010-6 Learning Perl, Fifth Edition |
9950
|
|
|
|
|
|
|
|
9951
|
|
|
|
|
|
|
# P.221 Capturing |
9952
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
9953
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
9954
|
|
|
|
|
|
|
|
9955
|
|
|
|
|
|
|
# \g{-1}, \g{-2}, \g{-3} --> \g{-1}, \g{-2}, \g{-3} |
9956
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) - (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9957
|
|
|
|
|
|
|
} |
9958
|
|
|
|
|
|
|
|
9959
|
0
|
0
|
|
|
|
0
|
# \g{1}, \g{2}, \g{3} --> \g{2}, \g{3}, \g{4} (only when multibyte anchoring is enable) |
9960
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \\g (?>\s*) \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
9961
|
|
|
|
|
|
|
if ($1 <= $parens) { |
9962
|
|
|
|
|
|
|
$char[$i] = '\\g{' . ($1 + 1) . '}'; |
9963
|
|
|
|
|
|
|
} |
9964
|
|
|
|
|
|
|
} |
9965
|
|
|
|
|
|
|
|
9966
|
0
|
0
|
|
|
|
0
|
# \g1, \g2, \g3 --> \g2, \g3, \g4 (only when multibyte anchoring is enable) |
9967
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \\g (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) { |
9968
|
|
|
|
|
|
|
if ($1 <= $parens) { |
9969
|
|
|
|
|
|
|
$char[$i] = '\\g' . ($1 + 1); |
9970
|
|
|
|
|
|
|
} |
9971
|
|
|
|
|
|
|
} |
9972
|
|
|
|
|
|
|
|
9973
|
0
|
0
|
|
|
|
0
|
# \1, \2, \3 --> \2, \3, \4 (only when multibyte anchoring is enable) |
9974
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \\ (?>\s*) ((?>[1-9][0-9]*)) \z/oxms) { |
9975
|
|
|
|
|
|
|
if ($1 <= $parens) { |
9976
|
|
|
|
|
|
|
$char[$i] = '\\' . ($1 + 1); |
9977
|
|
|
|
|
|
|
} |
9978
|
|
|
|
|
|
|
} |
9979
|
|
|
|
|
|
|
|
9980
|
0
|
0
|
|
|
|
0
|
# $0 --> $0 |
9981
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
9982
|
|
|
|
|
|
|
if ($ignorecase) { |
9983
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9984
|
|
|
|
|
|
|
} |
9985
|
0
|
0
|
|
|
|
0
|
} |
9986
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
9987
|
|
|
|
|
|
|
if ($ignorecase) { |
9988
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
9989
|
|
|
|
|
|
|
} |
9990
|
|
|
|
|
|
|
} |
9991
|
|
|
|
|
|
|
|
9992
|
|
|
|
|
|
|
# $$ --> $$ |
9993
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
9994
|
|
|
|
|
|
|
} |
9995
|
|
|
|
|
|
|
|
9996
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
9997
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
9998
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
9999
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10000
|
|
|
|
|
|
|
if ($ignorecase) { |
10001
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10002
|
|
|
|
|
|
|
} |
10003
|
0
|
|
|
|
|
0
|
} |
10004
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
10005
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10006
|
|
|
|
|
|
|
if ($ignorecase) { |
10007
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10008
|
|
|
|
|
|
|
} |
10009
|
|
|
|
|
|
|
} |
10010
|
|
|
|
|
|
|
|
10011
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
10012
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
10013
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
10014
|
|
|
|
|
|
|
if ($ignorecase) { |
10015
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10016
|
|
|
|
|
|
|
} |
10017
|
|
|
|
|
|
|
} |
10018
|
|
|
|
|
|
|
|
10019
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
10020
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
10021
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
10022
|
|
|
|
|
|
|
if ($ignorecase) { |
10023
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10024
|
|
|
|
|
|
|
} |
10025
|
|
|
|
|
|
|
} |
10026
|
|
|
|
|
|
|
|
10027
|
0
|
|
|
|
|
0
|
# $$foo |
10028
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
10029
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10030
|
|
|
|
|
|
|
if ($ignorecase) { |
10031
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10032
|
|
|
|
|
|
|
} |
10033
|
|
|
|
|
|
|
} |
10034
|
|
|
|
|
|
|
|
10035
|
0
|
50
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ehp15::PREMATCH() |
10036
|
4
|
|
|
|
|
20
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
10037
|
|
|
|
|
|
|
if ($ignorecase) { |
10038
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(Ehp15::PREMATCH())]}'; |
10039
|
0
|
|
|
|
|
0
|
} |
10040
|
|
|
|
|
|
|
else { |
10041
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::PREMATCH()]}'; |
10042
|
|
|
|
|
|
|
} |
10043
|
|
|
|
|
|
|
} |
10044
|
|
|
|
|
|
|
|
10045
|
4
|
50
|
|
|
|
19
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ehp15::MATCH() |
10046
|
4
|
|
|
|
|
18
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
10047
|
|
|
|
|
|
|
if ($ignorecase) { |
10048
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(Ehp15::MATCH())]}'; |
10049
|
0
|
|
|
|
|
0
|
} |
10050
|
|
|
|
|
|
|
else { |
10051
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::MATCH()]}'; |
10052
|
|
|
|
|
|
|
} |
10053
|
|
|
|
|
|
|
} |
10054
|
|
|
|
|
|
|
|
10055
|
4
|
50
|
|
|
|
18
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ehp15::POSTMATCH() |
10056
|
3
|
|
|
|
|
14
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
10057
|
|
|
|
|
|
|
if ($ignorecase) { |
10058
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(Ehp15::POSTMATCH())]}'; |
10059
|
0
|
|
|
|
|
0
|
} |
10060
|
|
|
|
|
|
|
else { |
10061
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::POSTMATCH()]}'; |
10062
|
|
|
|
|
|
|
} |
10063
|
|
|
|
|
|
|
} |
10064
|
|
|
|
|
|
|
|
10065
|
3
|
0
|
|
|
|
15
|
# ${ foo } |
10066
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
10067
|
|
|
|
|
|
|
if ($ignorecase) { |
10068
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10069
|
|
|
|
|
|
|
} |
10070
|
|
|
|
|
|
|
} |
10071
|
|
|
|
|
|
|
|
10072
|
0
|
|
|
|
|
0
|
# ${ ... } |
10073
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
10074
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10075
|
|
|
|
|
|
|
if ($ignorecase) { |
10076
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10077
|
|
|
|
|
|
|
} |
10078
|
|
|
|
|
|
|
} |
10079
|
|
|
|
|
|
|
|
10080
|
0
|
|
|
|
|
0
|
# $scalar or @array |
10081
|
13
|
50
|
|
|
|
57
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
10082
|
13
|
|
|
|
|
64
|
$char[$i] = e_string($char[$i]); |
10083
|
|
|
|
|
|
|
if ($ignorecase) { |
10084
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10085
|
|
|
|
|
|
|
} |
10086
|
|
|
|
|
|
|
} |
10087
|
|
|
|
|
|
|
|
10088
|
0
|
50
|
|
|
|
0
|
# quote character before ? + * { |
10089
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
10090
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
10091
|
23
|
|
|
|
|
130
|
} |
10092
|
|
|
|
|
|
|
else { |
10093
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
10094
|
|
|
|
|
|
|
} |
10095
|
|
|
|
|
|
|
} |
10096
|
|
|
|
|
|
|
} |
10097
|
23
|
|
|
|
|
131
|
|
10098
|
142
|
|
|
|
|
353
|
# make regexp string |
10099
|
142
|
|
|
|
|
368
|
my $prematch = ''; |
10100
|
142
|
50
|
|
|
|
257
|
$prematch = "($anchor)"; |
10101
|
142
|
|
|
|
|
386
|
$modifier =~ tr/i//d; |
10102
|
|
|
|
|
|
|
if ($left_e > $right_e) { |
10103
|
0
|
|
|
|
|
0
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, '>]}' x ($left_e - $right_e), ')', $matched, $end_delimiter, $modifier; |
10104
|
|
|
|
|
|
|
} |
10105
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10106
|
|
|
|
|
|
|
} |
10107
|
|
|
|
|
|
|
|
10108
|
|
|
|
|
|
|
# |
10109
|
|
|
|
|
|
|
# escape regexp (s'here'' or s'here''b) |
10110
|
142
|
|
|
96
|
0
|
1787
|
# |
10111
|
96
|
|
100
|
|
|
196
|
sub e_s1_q { |
10112
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10113
|
96
|
|
|
|
|
226
|
$modifier ||= ''; |
10114
|
96
|
50
|
|
|
|
120
|
|
10115
|
96
|
|
|
|
|
289
|
$modifier =~ tr/p//d; |
10116
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10117
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
10118
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10119
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
10120
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10121
|
|
|
|
|
|
|
last; |
10122
|
0
|
|
|
|
|
0
|
} |
10123
|
|
|
|
|
|
|
} |
10124
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10125
|
0
|
|
|
|
|
0
|
} |
10126
|
|
|
|
|
|
|
|
10127
|
|
|
|
|
|
|
$slash = 'div'; |
10128
|
96
|
100
|
|
|
|
131
|
|
|
|
100
|
|
|
|
|
|
10129
|
96
|
|
|
|
|
204
|
# literal null string pattern |
10130
|
8
|
|
|
|
|
9
|
if ($string eq '') { |
10131
|
8
|
|
|
|
|
11
|
$modifier =~ tr/bB//d; |
10132
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
10133
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $end_delimiter, $modifier; |
10134
|
|
|
|
|
|
|
} |
10135
|
|
|
|
|
|
|
|
10136
|
8
|
|
|
|
|
51
|
# with /b /B modifier |
10137
|
|
|
|
|
|
|
elsif ($modifier =~ tr/bB//d) { |
10138
|
|
|
|
|
|
|
return e_s1_qb($ope,$delimiter,$end_delimiter,$string,$modifier); |
10139
|
|
|
|
|
|
|
} |
10140
|
|
|
|
|
|
|
|
10141
|
44
|
|
|
|
|
87
|
# without /b /B modifier |
10142
|
|
|
|
|
|
|
else { |
10143
|
|
|
|
|
|
|
return e_s1_qt($ope,$delimiter,$end_delimiter,$string,$modifier); |
10144
|
|
|
|
|
|
|
} |
10145
|
|
|
|
|
|
|
} |
10146
|
|
|
|
|
|
|
|
10147
|
|
|
|
|
|
|
# |
10148
|
|
|
|
|
|
|
# escape regexp (s'here'') |
10149
|
44
|
|
|
44
|
0
|
89
|
# |
10150
|
|
|
|
|
|
|
sub e_s1_qt { |
10151
|
44
|
100
|
|
|
|
93
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10152
|
|
|
|
|
|
|
|
10153
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
10154
|
44
|
|
|
|
|
88
|
|
10155
|
|
|
|
|
|
|
# split regexp |
10156
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
10157
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\[\$\@\/] | |
10158
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
10159
|
|
|
|
|
|
|
\[\^ | |
10160
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
10161
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
10162
|
|
|
|
|
|
|
[\$\@\/] | |
10163
|
|
|
|
|
|
|
\\ (?:$q_char) | |
10164
|
|
|
|
|
|
|
(?:$q_char) |
10165
|
|
|
|
|
|
|
))/oxmsg; |
10166
|
44
|
|
|
|
|
469
|
|
10167
|
44
|
50
|
100
|
|
|
118
|
# unescape character |
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
10168
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10169
|
|
|
|
|
|
|
if (0) { |
10170
|
|
|
|
|
|
|
} |
10171
|
62
|
|
|
|
|
549
|
|
10172
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
10173
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10174
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10175
|
|
|
|
|
|
|
} |
10176
|
|
|
|
|
|
|
|
10177
|
0
|
|
|
|
|
0
|
# open character class [...] |
10178
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
10179
|
0
|
|
|
|
|
0
|
my $left = $i; |
10180
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
10181
|
0
|
|
|
|
|
0
|
$i++; |
10182
|
0
|
0
|
|
|
|
0
|
} |
10183
|
0
|
|
|
|
|
0
|
while (1) { |
10184
|
|
|
|
|
|
|
if (++$i > $#char) { |
10185
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10186
|
0
|
|
|
|
|
0
|
} |
10187
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10188
|
|
|
|
|
|
|
my $right = $i; |
10189
|
0
|
|
|
|
|
0
|
|
10190
|
|
|
|
|
|
|
# [...] |
10191
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Ehp15::charlist_qr(@char[$left+1..$right-1], $modifier); |
10192
|
0
|
|
|
|
|
0
|
|
10193
|
|
|
|
|
|
|
$i = $left; |
10194
|
|
|
|
|
|
|
last; |
10195
|
|
|
|
|
|
|
} |
10196
|
|
|
|
|
|
|
} |
10197
|
|
|
|
|
|
|
} |
10198
|
|
|
|
|
|
|
|
10199
|
0
|
|
|
|
|
0
|
# open character class [^...] |
10200
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
10201
|
0
|
|
|
|
|
0
|
my $left = $i; |
10202
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
10203
|
0
|
|
|
|
|
0
|
$i++; |
10204
|
0
|
0
|
|
|
|
0
|
} |
10205
|
0
|
|
|
|
|
0
|
while (1) { |
10206
|
|
|
|
|
|
|
if (++$i > $#char) { |
10207
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10208
|
0
|
|
|
|
|
0
|
} |
10209
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10210
|
|
|
|
|
|
|
my $right = $i; |
10211
|
0
|
|
|
|
|
0
|
|
10212
|
|
|
|
|
|
|
# [^...] |
10213
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Ehp15::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
10214
|
0
|
|
|
|
|
0
|
|
10215
|
|
|
|
|
|
|
$i = $left; |
10216
|
|
|
|
|
|
|
last; |
10217
|
|
|
|
|
|
|
} |
10218
|
|
|
|
|
|
|
} |
10219
|
|
|
|
|
|
|
} |
10220
|
|
|
|
|
|
|
|
10221
|
0
|
|
|
|
|
0
|
# escape $ @ / and \ |
10222
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10223
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10224
|
|
|
|
|
|
|
} |
10225
|
|
|
|
|
|
|
|
10226
|
0
|
|
|
|
|
0
|
# rewrite character class or escape character |
10227
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
10228
|
|
|
|
|
|
|
$char[$i] = $char; |
10229
|
|
|
|
|
|
|
} |
10230
|
|
|
|
|
|
|
|
10231
|
6
|
50
|
|
|
|
14
|
# /i modifier |
10232
|
8
|
|
|
|
|
18
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ehp15::uc($char[$i]) ne Ehp15::fc($char[$i]))) { |
10233
|
|
|
|
|
|
|
if (CORE::length(Ehp15::fc($char[$i])) == 1) { |
10234
|
|
|
|
|
|
|
$char[$i] = '[' . Ehp15::uc($char[$i]) . Ehp15::fc($char[$i]) . ']'; |
10235
|
8
|
|
|
|
|
18
|
} |
10236
|
|
|
|
|
|
|
else { |
10237
|
|
|
|
|
|
|
$char[$i] = '(?:' . Ehp15::uc($char[$i]) . '|' . Ehp15::fc($char[$i]) . ')'; |
10238
|
|
|
|
|
|
|
} |
10239
|
|
|
|
|
|
|
} |
10240
|
|
|
|
|
|
|
|
10241
|
0
|
0
|
|
|
|
0
|
# quote character before ? + * { |
10242
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
10243
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
10244
|
0
|
|
|
|
|
0
|
} |
10245
|
|
|
|
|
|
|
else { |
10246
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
10247
|
|
|
|
|
|
|
} |
10248
|
|
|
|
|
|
|
} |
10249
|
0
|
|
|
|
|
0
|
} |
10250
|
44
|
|
|
|
|
87
|
|
10251
|
44
|
|
|
|
|
64
|
$modifier =~ tr/i//d; |
10252
|
44
|
|
|
|
|
52
|
$delimiter = '/'; |
10253
|
44
|
|
|
|
|
55
|
$end_delimiter = '/'; |
10254
|
44
|
|
|
|
|
79
|
my $prematch = ''; |
10255
|
|
|
|
|
|
|
$prematch = "($anchor)"; |
10256
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10257
|
|
|
|
|
|
|
} |
10258
|
|
|
|
|
|
|
|
10259
|
|
|
|
|
|
|
# |
10260
|
|
|
|
|
|
|
# escape regexp (s'here''b) |
10261
|
44
|
|
|
44
|
0
|
302
|
# |
10262
|
|
|
|
|
|
|
sub e_s1_qb { |
10263
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10264
|
44
|
|
|
|
|
83
|
|
10265
|
|
|
|
|
|
|
# split regexp |
10266
|
|
|
|
|
|
|
my @char = $string =~ /\G (?>[^\\]|\\\\|[\x00-\xFF]) /oxmsg; |
10267
|
44
|
|
|
|
|
153
|
|
10268
|
44
|
50
|
|
|
|
102
|
# unescape character |
|
|
50
|
|
|
|
|
|
10269
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10270
|
|
|
|
|
|
|
if (0) { |
10271
|
|
|
|
|
|
|
} |
10272
|
98
|
|
|
|
|
282
|
|
10273
|
|
|
|
|
|
|
# remain \\ |
10274
|
|
|
|
|
|
|
elsif ($char[$i] eq '\\\\') { |
10275
|
|
|
|
|
|
|
} |
10276
|
|
|
|
|
|
|
|
10277
|
0
|
|
|
|
|
0
|
# escape $ @ / and \ |
10278
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10279
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10280
|
|
|
|
|
|
|
} |
10281
|
0
|
|
|
|
|
0
|
} |
10282
|
44
|
|
|
|
|
56
|
|
10283
|
44
|
|
|
|
|
49
|
$delimiter = '/'; |
10284
|
44
|
|
|
|
|
61
|
$end_delimiter = '/'; |
10285
|
44
|
|
|
|
|
49
|
my $prematch = ''; |
10286
|
|
|
|
|
|
|
$prematch = q{(\G[\x00-\xFF]*?)}; |
10287
|
|
|
|
|
|
|
return join '', $ope, $delimiter, $prematch, '(?:', @char, ')', $matched, $end_delimiter, $modifier; |
10288
|
|
|
|
|
|
|
} |
10289
|
|
|
|
|
|
|
|
10290
|
|
|
|
|
|
|
# |
10291
|
|
|
|
|
|
|
# escape regexp (s''here') |
10292
|
44
|
|
|
91
|
0
|
318
|
# |
10293
|
|
|
|
|
|
|
sub e_s2_q { |
10294
|
91
|
|
|
|
|
189
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10295
|
|
|
|
|
|
|
|
10296
|
91
|
|
|
|
|
109
|
$slash = 'div'; |
10297
|
91
|
|
|
|
|
326
|
|
10298
|
91
|
50
|
66
|
|
|
234
|
my @char = $string =~ / \G (?>[^\x80-\xA0\xE0-\xFE\\]|\\\\|$q_char) /oxmsg; |
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
10299
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10300
|
|
|
|
|
|
|
if (0) { |
10301
|
|
|
|
|
|
|
} |
10302
|
9
|
|
|
|
|
98
|
|
10303
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
10304
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) (\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10305
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10306
|
0
|
|
|
|
|
0
|
} |
10307
|
|
|
|
|
|
|
elsif (defined($char[$i+1]) and ($char[$i+1] eq '\\') and ($char[$i] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
10308
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10309
|
|
|
|
|
|
|
} |
10310
|
|
|
|
|
|
|
|
10311
|
|
|
|
|
|
|
# not escape \\ |
10312
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\\\ \z/oxms) { |
10313
|
|
|
|
|
|
|
} |
10314
|
|
|
|
|
|
|
|
10315
|
0
|
|
|
|
|
0
|
# escape $ @ / and \ |
10316
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A [\$\@\/\\] \z/oxms) { |
10317
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10318
|
5
|
50
|
66
|
|
|
17
|
} |
10319
|
91
|
|
|
|
|
223
|
} |
10320
|
|
|
|
|
|
|
if (defined($char[-1]) and ($char[-1] =~ /\A ([\x80-\xFF].*) (\\) \z/xms)) { |
10321
|
|
|
|
|
|
|
$char[-1] = $1 . '\\' . $2; |
10322
|
0
|
|
|
|
|
0
|
} |
10323
|
|
|
|
|
|
|
|
10324
|
|
|
|
|
|
|
return join '', $ope, $delimiter, @char, $end_delimiter; |
10325
|
|
|
|
|
|
|
} |
10326
|
|
|
|
|
|
|
|
10327
|
|
|
|
|
|
|
# |
10328
|
|
|
|
|
|
|
# escape regexp (s/here/and here/modifier) |
10329
|
91
|
|
|
290
|
0
|
264
|
# |
10330
|
290
|
|
100
|
|
|
2467
|
sub e_sub { |
10331
|
|
|
|
|
|
|
my($variable,$delimiter1,$pattern,$end_delimiter1,$delimiter2,$replacement,$end_delimiter2,$modifier) = @_; |
10332
|
290
|
|
|
|
|
1289
|
$modifier ||= ''; |
10333
|
290
|
50
|
|
|
|
604
|
|
10334
|
290
|
|
|
|
|
1016
|
$modifier =~ tr/p//d; |
10335
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10336
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
10337
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10338
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
10339
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10340
|
|
|
|
|
|
|
last; |
10341
|
0
|
|
|
|
|
0
|
} |
10342
|
|
|
|
|
|
|
} |
10343
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10344
|
0
|
100
|
|
|
|
0
|
} |
10345
|
290
|
|
|
|
|
803
|
|
10346
|
37
|
|
|
|
|
58
|
if ($variable eq '') { |
10347
|
|
|
|
|
|
|
$variable = '$_'; |
10348
|
|
|
|
|
|
|
$bind_operator = ' =~ '; |
10349
|
37
|
|
|
|
|
54
|
} |
10350
|
|
|
|
|
|
|
|
10351
|
|
|
|
|
|
|
$slash = 'div'; |
10352
|
|
|
|
|
|
|
|
10353
|
|
|
|
|
|
|
# P.128 Start of match (or end of previous match): \G |
10354
|
|
|
|
|
|
|
# P.130 Advanced Use of \G with Perl |
10355
|
|
|
|
|
|
|
# in Chapter 3: Overview of Regular Expression Features and Flavors |
10356
|
|
|
|
|
|
|
# P.312 Iterative Matching: Scalar Context, with /g |
10357
|
|
|
|
|
|
|
# in Chapter 7: Perl |
10358
|
|
|
|
|
|
|
# of ISBN 0-596-00289-0 Mastering Regular Expressions, Second edition |
10359
|
|
|
|
|
|
|
|
10360
|
|
|
|
|
|
|
# P.181 Where You Left Off: The \G Assertion |
10361
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
10362
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
10363
|
|
|
|
|
|
|
|
10364
|
|
|
|
|
|
|
# P.220 Where You Left Off: The \G Assertion |
10365
|
|
|
|
|
|
|
# in Chapter 5: Pattern Matching |
10366
|
290
|
|
|
|
|
467
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
10367
|
290
|
|
|
|
|
437
|
|
10368
|
|
|
|
|
|
|
my $e_modifier = $modifier =~ tr/e//d; |
10369
|
290
|
|
|
|
|
425
|
my $r_modifier = $modifier =~ tr/r//d; |
10370
|
290
|
50
|
|
|
|
506
|
|
10371
|
290
|
|
|
|
|
909
|
my $my = ''; |
10372
|
0
|
|
|
|
|
0
|
if ($variable =~ s/\A \( (?>\s*) ( (?>(?: local \b | my \b | our \b | state \b )?) .+ ) \) \z/$1/oxms) { |
10373
|
0
|
|
|
|
|
0
|
$my = $variable; |
10374
|
|
|
|
|
|
|
$variable =~ s/ (?: local \b | my \b | our \b | state \b ) (?>\s*) //oxms; |
10375
|
|
|
|
|
|
|
$variable =~ s/ = .+ \z//oxms; |
10376
|
0
|
|
|
|
|
0
|
} |
10377
|
290
|
|
|
|
|
703
|
|
10378
|
|
|
|
|
|
|
(my $variable_basename = $variable) =~ s/ [\[\{].* \z//oxms; |
10379
|
|
|
|
|
|
|
$variable_basename =~ s/ \s+ \z//oxms; |
10380
|
290
|
|
|
|
|
540
|
|
10381
|
290
|
100
|
|
|
|
420
|
# quote replacement string |
10382
|
290
|
|
|
|
|
637
|
my $e_replacement = ''; |
10383
|
17
|
|
|
|
|
41
|
if ($e_modifier >= 1) { |
10384
|
|
|
|
|
|
|
$e_replacement = e_qq('', '', '', $replacement); |
10385
|
|
|
|
|
|
|
$e_modifier--; |
10386
|
17
|
100
|
|
|
|
34
|
} |
10387
|
273
|
|
|
|
|
612
|
else { |
10388
|
|
|
|
|
|
|
if ($delimiter2 eq "'") { |
10389
|
|
|
|
|
|
|
$e_replacement = e_s2_q('qq', '/', '/', $replacement); |
10390
|
91
|
|
|
|
|
164
|
} |
10391
|
|
|
|
|
|
|
else { |
10392
|
|
|
|
|
|
|
$e_replacement = e_qq ('qq', $delimiter2, $end_delimiter2, $replacement); |
10393
|
|
|
|
|
|
|
} |
10394
|
182
|
|
|
|
|
435
|
} |
10395
|
|
|
|
|
|
|
|
10396
|
|
|
|
|
|
|
my $sub = ''; |
10397
|
290
|
100
|
|
|
|
529
|
|
10398
|
290
|
100
|
|
|
|
622
|
# with /r |
|
|
50
|
|
|
|
|
|
10399
|
|
|
|
|
|
|
if ($r_modifier) { |
10400
|
|
|
|
|
|
|
if (0) { |
10401
|
|
|
|
|
|
|
} |
10402
|
8
|
|
|
|
|
20
|
|
10403
|
0
|
50
|
|
|
|
0
|
# s///gr with multibyte anchoring |
10404
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10405
|
|
|
|
|
|
|
$sub = sprintf( |
10406
|
|
|
|
|
|
|
# 1 2 3 4 5 |
10407
|
|
|
|
|
|
|
q, |
10408
|
|
|
|
|
|
|
|
10409
|
|
|
|
|
|
|
$variable, # 1 |
10410
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10411
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10412
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10413
|
|
|
|
|
|
|
$s_matched, # 3 |
10414
|
|
|
|
|
|
|
$e_replacement, # 4 |
10415
|
|
|
|
|
|
|
'$Ehp15::re_r=CORE::eval $Ehp15::re_r; ' x $e_modifier, # 5 |
10416
|
|
|
|
|
|
|
); |
10417
|
|
|
|
|
|
|
} |
10418
|
|
|
|
|
|
|
|
10419
|
4
|
0
|
|
|
|
15
|
# s///gr without multibyte anchoring |
10420
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10421
|
|
|
|
|
|
|
$sub = sprintf( |
10422
|
|
|
|
|
|
|
# 1 2 3 4 5 |
10423
|
|
|
|
|
|
|
q, |
10424
|
|
|
|
|
|
|
|
10425
|
|
|
|
|
|
|
$variable, # 1 |
10426
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10427
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10428
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10429
|
|
|
|
|
|
|
$s_matched, # 3 |
10430
|
|
|
|
|
|
|
$e_replacement, # 4 |
10431
|
|
|
|
|
|
|
'$Ehp15::re_r=CORE::eval $Ehp15::re_r; ' x $e_modifier, # 5 |
10432
|
|
|
|
|
|
|
); |
10433
|
|
|
|
|
|
|
} |
10434
|
|
|
|
|
|
|
|
10435
|
|
|
|
|
|
|
# s///r |
10436
|
0
|
|
|
|
|
0
|
else { |
10437
|
4
|
|
|
|
|
6
|
|
10438
|
|
|
|
|
|
|
my $prematch = q{$`}; |
10439
|
4
|
50
|
|
|
|
7
|
$prematch = q{${1}}; |
10440
|
|
|
|
|
|
|
|
10441
|
|
|
|
|
|
|
$sub = sprintf( |
10442
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 |
10443
|
|
|
|
|
|
|
q<(%s =~ %s) ? CORE::eval{%s local $^W=0; local $Ehp15::re_r=%s; %s"%s$Ehp15::re_r$'" } : %s>, |
10444
|
|
|
|
|
|
|
|
10445
|
|
|
|
|
|
|
$variable, # 1 |
10446
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10447
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10448
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10449
|
|
|
|
|
|
|
$s_matched, # 3 |
10450
|
|
|
|
|
|
|
$e_replacement, # 4 |
10451
|
|
|
|
|
|
|
'$Ehp15::re_r=CORE::eval $Ehp15::re_r; ' x $e_modifier, # 5 |
10452
|
|
|
|
|
|
|
$prematch, # 6 |
10453
|
|
|
|
|
|
|
$variable, # 7 |
10454
|
|
|
|
|
|
|
); |
10455
|
|
|
|
|
|
|
} |
10456
|
4
|
50
|
|
|
|
16
|
|
10457
|
8
|
|
|
|
|
25
|
# $var !~ s///r doesn't make sense |
10458
|
|
|
|
|
|
|
if ($bind_operator =~ / !~ /oxms) { |
10459
|
|
|
|
|
|
|
$sub = q{die("$0: Using !~ with s///r doesn't make sense"), } . $sub; |
10460
|
|
|
|
|
|
|
} |
10461
|
|
|
|
|
|
|
} |
10462
|
|
|
|
|
|
|
|
10463
|
0
|
100
|
|
|
|
0
|
# without /r |
|
|
50
|
|
|
|
|
|
10464
|
|
|
|
|
|
|
else { |
10465
|
|
|
|
|
|
|
if (0) { |
10466
|
|
|
|
|
|
|
} |
10467
|
282
|
|
|
|
|
894
|
|
10468
|
0
|
100
|
|
|
|
0
|
# s///g with multibyte anchoring |
|
|
100
|
|
|
|
|
|
10469
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10470
|
|
|
|
|
|
|
$sub = sprintf( |
10471
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 9 10 |
10472
|
|
|
|
|
|
|
q, |
10473
|
|
|
|
|
|
|
|
10474
|
|
|
|
|
|
|
$variable, # 1 |
10475
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10476
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10477
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10478
|
|
|
|
|
|
|
$s_matched, # 3 |
10479
|
|
|
|
|
|
|
$e_replacement, # 4 |
10480
|
|
|
|
|
|
|
'$Ehp15::re_r=CORE::eval $Ehp15::re_r; ' x $e_modifier, # 5 |
10481
|
|
|
|
|
|
|
$variable, # 6 |
10482
|
|
|
|
|
|
|
$variable, # 7 |
10483
|
|
|
|
|
|
|
$variable, # 8 |
10484
|
|
|
|
|
|
|
$variable, # 9 |
10485
|
|
|
|
|
|
|
|
10486
|
|
|
|
|
|
|
# Binary "!~" is just like "=~" except the return value is negated in the logical sense. |
10487
|
|
|
|
|
|
|
# It returns false if the match succeeds, and true if it fails. |
10488
|
|
|
|
|
|
|
# (and so on) |
10489
|
|
|
|
|
|
|
|
10490
|
|
|
|
|
|
|
($bind_operator =~ / !~ /oxms) ? '!' : '', # 10 |
10491
|
|
|
|
|
|
|
); |
10492
|
|
|
|
|
|
|
} |
10493
|
|
|
|
|
|
|
|
10494
|
35
|
0
|
|
|
|
162
|
# s///g without multibyte anchoring |
|
|
0
|
|
|
|
|
|
10495
|
|
|
|
|
|
|
elsif ($modifier =~ /g/oxms) { |
10496
|
|
|
|
|
|
|
$sub = sprintf( |
10497
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10498
|
|
|
|
|
|
|
q, |
10499
|
|
|
|
|
|
|
|
10500
|
|
|
|
|
|
|
$variable, # 1 |
10501
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 2 |
10502
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10503
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10504
|
|
|
|
|
|
|
$s_matched, # 3 |
10505
|
|
|
|
|
|
|
$e_replacement, # 4 |
10506
|
|
|
|
|
|
|
'$Ehp15::re_r=CORE::eval $Ehp15::re_r; ' x $e_modifier, # 5 |
10507
|
|
|
|
|
|
|
$variable, # 6 |
10508
|
|
|
|
|
|
|
$variable, # 7 |
10509
|
|
|
|
|
|
|
($bind_operator =~ / !~ /oxms) ? '!' : '', # 8 |
10510
|
|
|
|
|
|
|
); |
10511
|
|
|
|
|
|
|
} |
10512
|
|
|
|
|
|
|
|
10513
|
|
|
|
|
|
|
# s/// |
10514
|
0
|
|
|
|
|
0
|
else { |
10515
|
247
|
|
|
|
|
491
|
|
10516
|
|
|
|
|
|
|
my $prematch = q{$`}; |
10517
|
247
|
100
|
|
|
|
338
|
$prematch = q{${1}}; |
|
|
100
|
|
|
|
|
|
10518
|
|
|
|
|
|
|
|
10519
|
|
|
|
|
|
|
$sub = sprintf( |
10520
|
|
|
|
|
|
|
|
10521
|
|
|
|
|
|
|
($bind_operator =~ / =~ /oxms) ? |
10522
|
|
|
|
|
|
|
|
10523
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10524
|
|
|
|
|
|
|
q<(%s%s%s) ? CORE::eval{%s local $^W=0; local $Ehp15::re_r=%s; %s%s="%s$Ehp15::re_r$'"; 1 } : undef> : |
10525
|
|
|
|
|
|
|
|
10526
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 |
10527
|
|
|
|
|
|
|
q<(%s%s%s) ? 1 : CORE::eval{%s local $^W=0; local $Ehp15::re_r=%s; %s%s="%s$Ehp15::re_r$'"; undef }>, |
10528
|
|
|
|
|
|
|
|
10529
|
|
|
|
|
|
|
$variable, # 1 |
10530
|
|
|
|
|
|
|
$bind_operator, # 2 |
10531
|
|
|
|
|
|
|
($delimiter1 eq "'") ? # 3 |
10532
|
|
|
|
|
|
|
e_s1_q('m', $delimiter1, $end_delimiter1, $pattern, $modifier) : # : |
10533
|
|
|
|
|
|
|
e_s1 ('m', $delimiter1, $end_delimiter1, $pattern, $modifier), # : |
10534
|
|
|
|
|
|
|
$s_matched, # 4 |
10535
|
|
|
|
|
|
|
$e_replacement, # 5 |
10536
|
|
|
|
|
|
|
'$Ehp15::re_r=CORE::eval $Ehp15::re_r; ' x $e_modifier, # 6 |
10537
|
|
|
|
|
|
|
$variable, # 7 |
10538
|
|
|
|
|
|
|
$prematch, # 8 |
10539
|
|
|
|
|
|
|
); |
10540
|
|
|
|
|
|
|
} |
10541
|
|
|
|
|
|
|
} |
10542
|
247
|
50
|
|
|
|
1286
|
|
10543
|
290
|
|
|
|
|
824
|
# (my $foo = $bar) =~ s/// --> (my $foo = $bar, CORE::eval { ... })[1] |
10544
|
|
|
|
|
|
|
if ($my ne '') { |
10545
|
|
|
|
|
|
|
$sub = "($my, $sub)[1]"; |
10546
|
|
|
|
|
|
|
} |
10547
|
0
|
|
|
|
|
0
|
|
10548
|
290
|
|
|
|
|
428
|
# clear s/// variable |
10549
|
|
|
|
|
|
|
$sub_variable = ''; |
10550
|
290
|
|
|
|
|
411
|
$bind_operator = ''; |
10551
|
|
|
|
|
|
|
|
10552
|
|
|
|
|
|
|
return $sub; |
10553
|
|
|
|
|
|
|
} |
10554
|
|
|
|
|
|
|
|
10555
|
|
|
|
|
|
|
# |
10556
|
|
|
|
|
|
|
# escape chdir (qq//, "") |
10557
|
290
|
|
|
0
|
0
|
2708
|
# |
10558
|
|
|
|
|
|
|
sub e_chdir { |
10559
|
0
|
0
|
|
|
|
0
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10560
|
0
|
0
|
|
|
|
0
|
|
10561
|
0
|
0
|
|
|
|
0
|
if ($^W) { |
10562
|
0
|
|
|
|
|
0
|
if (Ehp15::_MSWin32_5Cended_path($string)) { |
10563
|
0
|
|
|
|
|
0
|
if ($] !~ /^5\.005/oxms) { |
10564
|
|
|
|
|
|
|
warn <
|
10565
|
|
|
|
|
|
|
@{[__FILE__]}: Can't chdir to '$string' |
10566
|
|
|
|
|
|
|
|
10567
|
|
|
|
|
|
|
chdir does not work with chr(0x5C) at end of path |
10568
|
|
|
|
|
|
|
http://bugs.activestate.com/show_bug.cgi?id=81839 |
10569
|
|
|
|
|
|
|
END |
10570
|
|
|
|
|
|
|
} |
10571
|
|
|
|
|
|
|
} |
10572
|
0
|
|
|
|
|
0
|
} |
10573
|
|
|
|
|
|
|
|
10574
|
|
|
|
|
|
|
return e_qq($ope,$delimiter,$end_delimiter,$string); |
10575
|
|
|
|
|
|
|
} |
10576
|
|
|
|
|
|
|
|
10577
|
|
|
|
|
|
|
# |
10578
|
|
|
|
|
|
|
# escape chdir (q//, '') |
10579
|
0
|
|
|
2
|
0
|
0
|
# |
10580
|
|
|
|
|
|
|
sub e_chdir_q { |
10581
|
2
|
50
|
|
|
|
7
|
my($ope,$delimiter,$end_delimiter,$string) = @_; |
10582
|
2
|
0
|
|
|
|
82
|
|
10583
|
0
|
0
|
|
|
|
0
|
if ($^W) { |
10584
|
0
|
|
|
|
|
0
|
if (Ehp15::_MSWin32_5Cended_path($string)) { |
10585
|
0
|
|
|
|
|
0
|
if ($] !~ /^5\.005/oxms) { |
10586
|
|
|
|
|
|
|
warn <
|
10587
|
|
|
|
|
|
|
@{[__FILE__]}: Can't chdir to '$string' |
10588
|
|
|
|
|
|
|
|
10589
|
|
|
|
|
|
|
chdir does not work with chr(0x5C) at end of path |
10590
|
|
|
|
|
|
|
http://bugs.activestate.com/show_bug.cgi?id=81839 |
10591
|
|
|
|
|
|
|
END |
10592
|
|
|
|
|
|
|
} |
10593
|
|
|
|
|
|
|
} |
10594
|
0
|
|
|
|
|
0
|
} |
10595
|
|
|
|
|
|
|
|
10596
|
|
|
|
|
|
|
return e_q($ope,$delimiter,$end_delimiter,$string); |
10597
|
|
|
|
|
|
|
} |
10598
|
|
|
|
|
|
|
|
10599
|
|
|
|
|
|
|
# |
10600
|
|
|
|
|
|
|
# escape regexp of split qr// |
10601
|
2
|
|
|
273
|
0
|
17
|
# |
10602
|
273
|
|
100
|
|
|
1165
|
sub e_split { |
10603
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10604
|
273
|
|
|
|
|
988
|
$modifier ||= ''; |
10605
|
273
|
50
|
|
|
|
508
|
|
10606
|
273
|
|
|
|
|
651
|
$modifier =~ tr/p//d; |
10607
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10608
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
10609
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10610
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
10611
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10612
|
|
|
|
|
|
|
last; |
10613
|
0
|
|
|
|
|
0
|
} |
10614
|
|
|
|
|
|
|
} |
10615
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10616
|
0
|
|
|
|
|
0
|
} |
10617
|
|
|
|
|
|
|
|
10618
|
|
|
|
|
|
|
$slash = 'div'; |
10619
|
273
|
100
|
|
|
|
416
|
|
10620
|
273
|
|
|
|
|
561
|
# /b /B modifier |
10621
|
|
|
|
|
|
|
if ($modifier =~ tr/bB//d) { |
10622
|
|
|
|
|
|
|
return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier; |
10623
|
84
|
100
|
|
|
|
386
|
} |
10624
|
189
|
|
|
|
|
593
|
|
10625
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
10626
|
|
|
|
|
|
|
my $metachar = qr/[\@\\|[\]{^]/oxms; |
10627
|
189
|
|
|
|
|
655
|
|
10628
|
|
|
|
|
|
|
# split regexp |
10629
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
10630
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\$\@\[\(]|[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
10631
|
|
|
|
|
|
|
\\x (?>[0-9A-Fa-f]{1,2}) | |
10632
|
|
|
|
|
|
|
\\ (?>[0-7]{2,3}) | |
10633
|
|
|
|
|
|
|
\\c [\x40-\x5F] | |
10634
|
|
|
|
|
|
|
\\x\{ (?>[0-9A-Fa-f]+) \} | |
10635
|
|
|
|
|
|
|
\\o\{ (?>[0-7]+) \} | |
10636
|
|
|
|
|
|
|
\\[bBNpP]\{ (?>[^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} | |
10637
|
|
|
|
|
|
|
\\ $q_char | |
10638
|
|
|
|
|
|
|
\$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} | |
10639
|
|
|
|
|
|
|
\$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} | |
10640
|
|
|
|
|
|
|
\$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} | |
10641
|
|
|
|
|
|
|
[\$\@] $qq_variable | |
10642
|
|
|
|
|
|
|
\$ (?>\s* [0-9]+) | |
10643
|
|
|
|
|
|
|
\$ (?>\s*) \{ (?>\s* [0-9]+ \s*) \} | |
10644
|
|
|
|
|
|
|
\$ \$ (?![\w\{]) | |
10645
|
|
|
|
|
|
|
\$ (?>\s*) \$ (?>\s*) $qq_variable | |
10646
|
|
|
|
|
|
|
\[\^ | |
10647
|
|
|
|
|
|
|
\[\: (?>[a-z]+) :\] | |
10648
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) :\] | |
10649
|
|
|
|
|
|
|
\(\? | |
10650
|
|
|
|
|
|
|
$q_char |
10651
|
189
|
|
|
|
|
16736
|
))/oxmsg; |
10652
|
189
|
|
|
|
|
565
|
|
10653
|
189
|
|
|
|
|
253
|
my $left_e = 0; |
10654
|
|
|
|
|
|
|
my $right_e = 0; |
10655
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
10656
|
189
|
50
|
33
|
|
|
509
|
|
|
|
50
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
10657
|
372
|
|
|
|
|
2313
|
# "\L\u" --> "\u\L" |
10658
|
|
|
|
|
|
|
if (($char[$i] eq '\L') and ($char[$i+1] eq '\u')) { |
10659
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10660
|
|
|
|
|
|
|
} |
10661
|
|
|
|
|
|
|
|
10662
|
0
|
|
|
|
|
0
|
# "\U\l" --> "\l\U" |
10663
|
|
|
|
|
|
|
elsif (($char[$i] eq '\U') and ($char[$i+1] eq '\l')) { |
10664
|
|
|
|
|
|
|
@char[$i,$i+1] = @char[$i+1,$i]; |
10665
|
|
|
|
|
|
|
} |
10666
|
|
|
|
|
|
|
|
10667
|
0
|
|
|
|
|
0
|
# octal escape sequence |
10668
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\o \{ ([0-7]+) \} \z/oxms) { |
10669
|
|
|
|
|
|
|
$char[$i] = Ehp15::octchr($1); |
10670
|
|
|
|
|
|
|
} |
10671
|
|
|
|
|
|
|
|
10672
|
1
|
|
|
|
|
3
|
# hexadecimal escape sequence |
10673
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\x \{ ([0-9A-Fa-f]+) \} \z/oxms) { |
10674
|
|
|
|
|
|
|
$char[$i] = Ehp15::hexchr($1); |
10675
|
|
|
|
|
|
|
} |
10676
|
|
|
|
|
|
|
|
10677
|
|
|
|
|
|
|
# \b{...} --> b\{...} |
10678
|
|
|
|
|
|
|
# \B{...} --> B\{...} |
10679
|
|
|
|
|
|
|
# \N{CHARNAME} --> N\{CHARNAME} |
10680
|
|
|
|
|
|
|
# \p{PROPERTY} --> p\{PROPERTY} |
10681
|
1
|
|
|
|
|
3
|
# \P{PROPERTY} --> P\{PROPERTY} |
10682
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ([bBNpP]) ( \{ ([^\x80-\xA0\xE0-\xFE0-9\}][^\x80-\xA0\xE0-\xFE\}]*) \} ) \z/oxms) { |
10683
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10684
|
|
|
|
|
|
|
} |
10685
|
|
|
|
|
|
|
|
10686
|
0
|
|
|
|
|
0
|
# \p, \P, \X --> p, P, X |
10687
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\ ( [pPX] ) \z/oxms) { |
10688
|
|
|
|
|
|
|
$char[$i] = $1; |
10689
|
0
|
50
|
100
|
|
|
0
|
} |
|
|
50
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
10690
|
|
|
|
|
|
|
|
10691
|
|
|
|
|
|
|
if (0) { |
10692
|
|
|
|
|
|
|
} |
10693
|
372
|
|
|
|
|
3371
|
|
10694
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
10695
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \\? ([\x80-\xFF].*) ($metachar|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
10696
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
10697
|
|
|
|
|
|
|
} |
10698
|
|
|
|
|
|
|
|
10699
|
0
|
0
|
0
|
|
|
0
|
# join separated multiple-octet |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
10700
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms) { |
10701
|
|
|
|
|
|
|
if ( ($i+3 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+3]) == 3) and (CORE::eval(sprintf '"%s%s%s%s"', @char[$i..$i+3]) =~ /\A $q_char \z/oxms)) { |
10702
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 3; |
10703
|
0
|
|
|
|
|
0
|
} |
10704
|
|
|
|
|
|
|
elsif (($i+2 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, @char[$i+1..$i+2]) == 2) and (CORE::eval(sprintf '"%s%s%s"', @char[$i..$i+2]) =~ /\A $q_char \z/oxms)) { |
10705
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 2; |
10706
|
0
|
|
|
|
|
0
|
} |
10707
|
|
|
|
|
|
|
elsif (($i+1 <= $#char) and (grep(/\A (?: \\ [0-7]{2,3} | \\x [0-9A-Fa-f]{1,2}) \z/oxms, $char[$i+1 ]) == 1) and (CORE::eval(sprintf '"%s%s"', @char[$i..$i+1]) =~ /\A $q_char \z/oxms)) { |
10708
|
|
|
|
|
|
|
$char[$i] .= join '', splice @char, $i+1, 1; |
10709
|
|
|
|
|
|
|
} |
10710
|
|
|
|
|
|
|
} |
10711
|
|
|
|
|
|
|
|
10712
|
0
|
|
|
|
|
0
|
# open character class [...] |
10713
|
3
|
50
|
|
|
|
5
|
elsif ($char[$i] eq '[') { |
10714
|
3
|
|
|
|
|
10
|
my $left = $i; |
10715
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
10716
|
0
|
|
|
|
|
0
|
$i++; |
10717
|
3
|
50
|
|
|
|
5
|
} |
10718
|
7
|
|
|
|
|
14
|
while (1) { |
10719
|
|
|
|
|
|
|
if (++$i > $#char) { |
10720
|
0
|
100
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10721
|
7
|
|
|
|
|
15
|
} |
10722
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10723
|
|
|
|
|
|
|
my $right = $i; |
10724
|
3
|
50
|
|
|
|
3
|
|
10725
|
3
|
|
|
|
|
22
|
# [...] |
|
0
|
|
|
|
|
0
|
|
10726
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
10727
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Ehp15::charlist_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
10728
|
0
|
|
|
|
|
0
|
} |
10729
|
|
|
|
|
|
|
else { |
10730
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Ehp15::charlist_qr(@char[$left+1..$right-1], $modifier); |
10731
|
3
|
|
|
|
|
16
|
} |
10732
|
3
|
|
|
|
|
6
|
|
10733
|
|
|
|
|
|
|
$i = $left; |
10734
|
|
|
|
|
|
|
last; |
10735
|
|
|
|
|
|
|
} |
10736
|
|
|
|
|
|
|
} |
10737
|
|
|
|
|
|
|
} |
10738
|
|
|
|
|
|
|
|
10739
|
3
|
|
|
|
|
8
|
# open character class [^...] |
10740
|
1
|
50
|
|
|
|
2
|
elsif ($char[$i] eq '[^') { |
10741
|
1
|
|
|
|
|
4
|
my $left = $i; |
10742
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
10743
|
0
|
|
|
|
|
0
|
$i++; |
10744
|
1
|
50
|
|
|
|
2
|
} |
10745
|
2
|
|
|
|
|
4
|
while (1) { |
10746
|
|
|
|
|
|
|
if (++$i > $#char) { |
10747
|
0
|
100
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
10748
|
2
|
|
|
|
|
7
|
} |
10749
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
10750
|
|
|
|
|
|
|
my $right = $i; |
10751
|
1
|
50
|
|
|
|
1
|
|
10752
|
1
|
|
|
|
|
8
|
# [^...] |
|
0
|
|
|
|
|
0
|
|
10753
|
|
|
|
|
|
|
if (grep(/\A [\$\@]/oxms,@char[$left+1..$right-1]) >= 1) { |
10754
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, sprintf(q{@{[Ehp15::charlist_not_qr(%s,'%s')]}}, join(',', map {qq_stuff($delimiter,$end_delimiter,$_)} @char[$left+1..$right-1]), $modifier); |
10755
|
0
|
|
|
|
|
0
|
} |
10756
|
|
|
|
|
|
|
else { |
10757
|
|
|
|
|
|
|
splice @char, $left, $right-$left+1, Ehp15::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
10758
|
1
|
|
|
|
|
22
|
} |
10759
|
1
|
|
|
|
|
2
|
|
10760
|
|
|
|
|
|
|
$i = $left; |
10761
|
|
|
|
|
|
|
last; |
10762
|
|
|
|
|
|
|
} |
10763
|
|
|
|
|
|
|
} |
10764
|
|
|
|
|
|
|
} |
10765
|
|
|
|
|
|
|
|
10766
|
1
|
|
|
|
|
3
|
# rewrite character class or escape character |
10767
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
10768
|
|
|
|
|
|
|
$char[$i] = $char; |
10769
|
|
|
|
|
|
|
} |
10770
|
|
|
|
|
|
|
|
10771
|
|
|
|
|
|
|
# P.794 29.2.161. split |
10772
|
|
|
|
|
|
|
# in Chapter 29: Functions |
10773
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
10774
|
|
|
|
|
|
|
|
10775
|
|
|
|
|
|
|
# P.951 split |
10776
|
|
|
|
|
|
|
# in Chapter 27: Functions |
10777
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
10778
|
|
|
|
|
|
|
|
10779
|
|
|
|
|
|
|
# said "The //m modifier is assumed when you split on the pattern /^/", |
10780
|
|
|
|
|
|
|
# but perl5.008 is not so. Therefore, this software adds //m. |
10781
|
|
|
|
|
|
|
# (and so on) |
10782
|
|
|
|
|
|
|
|
10783
|
5
|
|
|
|
|
17
|
# split(m/^/) --> split(m/^/m) |
10784
|
|
|
|
|
|
|
elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) { |
10785
|
|
|
|
|
|
|
$modifier .= 'm'; |
10786
|
|
|
|
|
|
|
} |
10787
|
|
|
|
|
|
|
|
10788
|
11
|
50
|
|
|
|
40
|
# /i modifier |
10789
|
18
|
|
|
|
|
38
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ehp15::uc($char[$i]) ne Ehp15::fc($char[$i]))) { |
10790
|
|
|
|
|
|
|
if (CORE::length(Ehp15::fc($char[$i])) == 1) { |
10791
|
|
|
|
|
|
|
$char[$i] = '[' . Ehp15::uc($char[$i]) . Ehp15::fc($char[$i]) . ']'; |
10792
|
18
|
|
|
|
|
38
|
} |
10793
|
|
|
|
|
|
|
else { |
10794
|
|
|
|
|
|
|
$char[$i] = '(?:' . Ehp15::uc($char[$i]) . '|' . Ehp15::fc($char[$i]) . ')'; |
10795
|
|
|
|
|
|
|
} |
10796
|
|
|
|
|
|
|
} |
10797
|
|
|
|
|
|
|
|
10798
|
0
|
50
|
|
|
|
0
|
# \u \l \U \L \F \Q \E |
10799
|
2
|
|
|
|
|
8
|
elsif ($char[$i] =~ /\A ([<>]) \z/oxms) { |
10800
|
|
|
|
|
|
|
if ($right_e < $left_e) { |
10801
|
|
|
|
|
|
|
$char[$i] = '\\' . $char[$i]; |
10802
|
|
|
|
|
|
|
} |
10803
|
0
|
|
|
|
|
0
|
} |
10804
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\u') { |
10805
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ucfirst qq<'; |
10806
|
|
|
|
|
|
|
$left_e++; |
10807
|
0
|
|
|
|
|
0
|
} |
10808
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\l') { |
10809
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::lcfirst qq<'; |
10810
|
|
|
|
|
|
|
$left_e++; |
10811
|
0
|
|
|
|
|
0
|
} |
10812
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\U') { |
10813
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::uc qq<'; |
10814
|
|
|
|
|
|
|
$left_e++; |
10815
|
0
|
|
|
|
|
0
|
} |
10816
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\L') { |
10817
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::lc qq<'; |
10818
|
|
|
|
|
|
|
$left_e++; |
10819
|
0
|
|
|
|
|
0
|
} |
10820
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\F') { |
10821
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::fc qq<'; |
10822
|
|
|
|
|
|
|
$left_e++; |
10823
|
0
|
|
|
|
|
0
|
} |
10824
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
10825
|
|
|
|
|
|
|
$char[$i] = '@{[CORE::quotemeta qq<'; |
10826
|
|
|
|
|
|
|
$left_e++; |
10827
|
0
|
0
|
|
|
|
0
|
} |
10828
|
0
|
|
|
|
|
0
|
elsif ($char[$i] eq '\E') { |
10829
|
0
|
|
|
|
|
0
|
if ($right_e < $left_e) { |
10830
|
|
|
|
|
|
|
$char[$i] = '>]}'; |
10831
|
|
|
|
|
|
|
$right_e++; |
10832
|
0
|
|
|
|
|
0
|
} |
10833
|
|
|
|
|
|
|
else { |
10834
|
|
|
|
|
|
|
$char[$i] = ''; |
10835
|
|
|
|
|
|
|
} |
10836
|
0
|
|
|
|
|
0
|
} |
10837
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '\Q') { |
10838
|
0
|
|
|
|
|
0
|
while (1) { |
10839
|
|
|
|
|
|
|
if (++$i > $#char) { |
10840
|
0
|
0
|
|
|
|
0
|
last; |
10841
|
0
|
|
|
|
|
0
|
} |
10842
|
|
|
|
|
|
|
if ($char[$i] eq '\E') { |
10843
|
|
|
|
|
|
|
last; |
10844
|
|
|
|
|
|
|
} |
10845
|
|
|
|
|
|
|
} |
10846
|
|
|
|
|
|
|
} |
10847
|
|
|
|
|
|
|
elsif ($char[$i] eq '\E') { |
10848
|
|
|
|
|
|
|
} |
10849
|
|
|
|
|
|
|
|
10850
|
0
|
0
|
|
|
|
0
|
# $0 --> $0 |
10851
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ 0 \z/oxms) { |
10852
|
|
|
|
|
|
|
if ($ignorecase) { |
10853
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10854
|
|
|
|
|
|
|
} |
10855
|
0
|
0
|
|
|
|
0
|
} |
10856
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) 0 (?>\s*) \} \z/oxms) { |
10857
|
|
|
|
|
|
|
if ($ignorecase) { |
10858
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10859
|
|
|
|
|
|
|
} |
10860
|
|
|
|
|
|
|
} |
10861
|
|
|
|
|
|
|
|
10862
|
|
|
|
|
|
|
# $$ --> $$ |
10863
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A \$\$ \z/oxms) { |
10864
|
|
|
|
|
|
|
} |
10865
|
|
|
|
|
|
|
|
10866
|
|
|
|
|
|
|
# $1, $2, $3 --> $2, $3, $4 after s/// with multibyte anchoring |
10867
|
0
|
|
|
|
|
0
|
# $1, $2, $3 --> $1, $2, $3 otherwise |
10868
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?>[1-9][0-9]*)) \z/oxms) { |
10869
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10870
|
|
|
|
|
|
|
if ($ignorecase) { |
10871
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10872
|
|
|
|
|
|
|
} |
10873
|
0
|
|
|
|
|
0
|
} |
10874
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ \{ (?>\s*) ((?>[1-9][0-9]*)) (?>\s*) \} \z/oxms) { |
10875
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10876
|
|
|
|
|
|
|
if ($ignorecase) { |
10877
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10878
|
|
|
|
|
|
|
} |
10879
|
|
|
|
|
|
|
} |
10880
|
|
|
|
|
|
|
|
10881
|
0
|
|
|
|
|
0
|
# $$foo[ ... ] --> $ $foo->[ ... ] |
10882
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \[ (?:$qq_bracket)*? \] ) \z/oxms) { |
10883
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
10884
|
|
|
|
|
|
|
if ($ignorecase) { |
10885
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10886
|
|
|
|
|
|
|
} |
10887
|
|
|
|
|
|
|
} |
10888
|
|
|
|
|
|
|
|
10889
|
0
|
|
|
|
|
0
|
# $$foo{ ... } --> $ $foo->{ ... } |
10890
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) ( \{ (?:$qq_brace)*? \} ) \z/oxms) { |
10891
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1.'->'.$2); |
10892
|
|
|
|
|
|
|
if ($ignorecase) { |
10893
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10894
|
|
|
|
|
|
|
} |
10895
|
|
|
|
|
|
|
} |
10896
|
|
|
|
|
|
|
|
10897
|
0
|
|
|
|
|
0
|
# $$foo |
10898
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ ((?> \$ [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* )) \z/oxms) { |
10899
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10900
|
|
|
|
|
|
|
if ($ignorecase) { |
10901
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10902
|
|
|
|
|
|
|
} |
10903
|
|
|
|
|
|
|
} |
10904
|
|
|
|
|
|
|
|
10905
|
0
|
50
|
|
|
|
0
|
# $`, ${`}, $PREMATCH, ${PREMATCH}, ${^PREMATCH} --> Ehp15::PREMATCH() |
10906
|
12
|
|
|
|
|
36
|
elsif ($char[$i] =~ /\A ( \$` | \$\{`\} | \$ (?>\s*) PREMATCH | \$ (?>\s*) \{ (?>\s*) PREMATCH (?>\s*) \} | \$ (?>\s*) \{\^PREMATCH\} ) \z/oxmsgc) { |
10907
|
|
|
|
|
|
|
if ($ignorecase) { |
10908
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(Ehp15::PREMATCH())]}'; |
10909
|
0
|
|
|
|
|
0
|
} |
10910
|
|
|
|
|
|
|
else { |
10911
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::PREMATCH()]}'; |
10912
|
|
|
|
|
|
|
} |
10913
|
|
|
|
|
|
|
} |
10914
|
|
|
|
|
|
|
|
10915
|
12
|
50
|
|
|
|
61
|
# $&, ${&}, $MATCH, ${MATCH}, ${^MATCH} --> Ehp15::MATCH() |
10916
|
12
|
|
|
|
|
32
|
elsif ($char[$i] =~ /\A ( \$& | \$\{&\} | \$ (?>\s*) MATCH | \$ (?>\s*) \{ (?>\s*) MATCH (?>\s*) \} | \$ (?>\s*) \{\^MATCH\} ) \z/oxmsgc) { |
10917
|
|
|
|
|
|
|
if ($ignorecase) { |
10918
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(Ehp15::MATCH())]}'; |
10919
|
0
|
|
|
|
|
0
|
} |
10920
|
|
|
|
|
|
|
else { |
10921
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::MATCH()]}'; |
10922
|
|
|
|
|
|
|
} |
10923
|
|
|
|
|
|
|
} |
10924
|
|
|
|
|
|
|
|
10925
|
12
|
50
|
|
|
|
55
|
# $POSTMATCH, ${POSTMATCH}, ${^POSTMATCH} --> Ehp15::POSTMATCH() |
10926
|
9
|
|
|
|
|
27
|
elsif ($char[$i] =~ /\A ( \$ (?>\s*) POSTMATCH | \$ (?>\s*) \{ (?>\s*) POSTMATCH (?>\s*) \} | \$ (?>\s*) \{\^POSTMATCH\} ) \z/oxmsgc) { |
10927
|
|
|
|
|
|
|
if ($ignorecase) { |
10928
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(Ehp15::POSTMATCH())]}'; |
10929
|
0
|
|
|
|
|
0
|
} |
10930
|
|
|
|
|
|
|
else { |
10931
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::POSTMATCH()]}'; |
10932
|
|
|
|
|
|
|
} |
10933
|
|
|
|
|
|
|
} |
10934
|
|
|
|
|
|
|
|
10935
|
9
|
0
|
|
|
|
47
|
# ${ foo } |
10936
|
0
|
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ((?> \s* [A-Za-z_][A-Za-z0-9_]*(?: ::[A-Za-z_][A-Za-z0-9_]*)* \s* )) \} \z/oxms) { |
10937
|
|
|
|
|
|
|
if ($ignorecase) { |
10938
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $1 . ')]}'; |
10939
|
|
|
|
|
|
|
} |
10940
|
|
|
|
|
|
|
} |
10941
|
|
|
|
|
|
|
|
10942
|
0
|
|
|
|
|
0
|
# ${ ... } |
10943
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] =~ /\A \$ (?>\s*) \{ ( .+ ) \} \z/oxms) { |
10944
|
0
|
|
|
|
|
0
|
$char[$i] = e_capture($1); |
10945
|
|
|
|
|
|
|
if ($ignorecase) { |
10946
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10947
|
|
|
|
|
|
|
} |
10948
|
|
|
|
|
|
|
} |
10949
|
|
|
|
|
|
|
|
10950
|
0
|
|
|
|
|
0
|
# $scalar or @array |
10951
|
3
|
50
|
|
|
|
11
|
elsif ($char[$i] =~ /\A [\$\@].+ /oxms) { |
10952
|
3
|
|
|
|
|
15
|
$char[$i] = e_string($char[$i]); |
10953
|
|
|
|
|
|
|
if ($ignorecase) { |
10954
|
|
|
|
|
|
|
$char[$i] = '@{[Ehp15::ignorecase(' . $char[$i] . ')]}'; |
10955
|
|
|
|
|
|
|
} |
10956
|
|
|
|
|
|
|
} |
10957
|
|
|
|
|
|
|
|
10958
|
0
|
100
|
|
|
|
0
|
# quote character before ? + * { |
10959
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
10960
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A (?:[\x00-\xFF]|\\[0-7]{2,3}|\\x[0-9-A-Fa-f]{1,2}) \z/oxms) { |
10961
|
7
|
|
|
|
|
46
|
} |
10962
|
|
|
|
|
|
|
else { |
10963
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
10964
|
|
|
|
|
|
|
} |
10965
|
|
|
|
|
|
|
} |
10966
|
|
|
|
|
|
|
} |
10967
|
4
|
|
|
|
|
25
|
|
10968
|
189
|
50
|
|
|
|
406
|
# make regexp string |
10969
|
189
|
|
|
|
|
400
|
$modifier =~ tr/i//d; |
10970
|
|
|
|
|
|
|
if ($left_e > $right_e) { |
10971
|
0
|
|
|
|
|
0
|
return join '', 'Ehp15::split', $ope, $delimiter, @char, '>]}' x ($left_e - $right_e), $end_delimiter, $modifier; |
10972
|
|
|
|
|
|
|
} |
10973
|
|
|
|
|
|
|
return join '', 'Ehp15::split', $ope, $delimiter, @char, $end_delimiter, $modifier; |
10974
|
|
|
|
|
|
|
} |
10975
|
|
|
|
|
|
|
|
10976
|
|
|
|
|
|
|
# |
10977
|
|
|
|
|
|
|
# escape regexp of split qr'' |
10978
|
189
|
|
|
112
|
0
|
1667
|
# |
10979
|
112
|
|
100
|
|
|
747
|
sub e_split_q { |
10980
|
|
|
|
|
|
|
my($ope,$delimiter,$end_delimiter,$string,$modifier) = @_; |
10981
|
112
|
|
|
|
|
509
|
$modifier ||= ''; |
10982
|
112
|
50
|
|
|
|
343
|
|
10983
|
112
|
|
|
|
|
375
|
$modifier =~ tr/p//d; |
10984
|
0
|
|
|
|
|
0
|
if ($modifier =~ /([adlu])/oxms) { |
10985
|
0
|
0
|
|
|
|
0
|
my $line = 0; |
10986
|
0
|
|
|
|
|
0
|
for (my $i=0; my($package,$filename,$use_line,$subroutine) = caller($i); $i++) { |
10987
|
0
|
|
|
|
|
0
|
if ($filename ne __FILE__) { |
10988
|
|
|
|
|
|
|
$line = $use_line + (CORE::substr($_,0,pos($_)) =~ tr/\n//) + 1; |
10989
|
|
|
|
|
|
|
last; |
10990
|
0
|
|
|
|
|
0
|
} |
10991
|
|
|
|
|
|
|
} |
10992
|
|
|
|
|
|
|
die qq{Unsupported modifier "$1" used at line $line.\n}; |
10993
|
0
|
|
|
|
|
0
|
} |
10994
|
|
|
|
|
|
|
|
10995
|
|
|
|
|
|
|
$slash = 'div'; |
10996
|
112
|
100
|
|
|
|
208
|
|
10997
|
112
|
|
|
|
|
246
|
# /b /B modifier |
10998
|
|
|
|
|
|
|
if ($modifier =~ tr/bB//d) { |
10999
|
|
|
|
|
|
|
return join '', 'split', $ope, $delimiter, $string, $end_delimiter, $modifier; |
11000
|
56
|
100
|
|
|
|
272
|
} |
11001
|
|
|
|
|
|
|
|
11002
|
|
|
|
|
|
|
my $ignorecase = ($modifier =~ /i/oxms) ? 1 : 0; |
11003
|
56
|
|
|
|
|
143
|
|
11004
|
|
|
|
|
|
|
# split regexp |
11005
|
|
|
|
|
|
|
my @char = $string =~ /\G((?> |
11006
|
|
|
|
|
|
|
[^\x80-\xA0\xE0-\xFE\\\[] | |
11007
|
|
|
|
|
|
|
[\x80-\xA0\xE0-\xFE][\x00-\xFF] | |
11008
|
|
|
|
|
|
|
\[\^ | |
11009
|
|
|
|
|
|
|
\[\: (?>[a-z]+) \:\] | |
11010
|
|
|
|
|
|
|
\[\:\^ (?>[a-z]+) \:\] | |
11011
|
|
|
|
|
|
|
\\ (?:$q_char) | |
11012
|
|
|
|
|
|
|
(?:$q_char) |
11013
|
|
|
|
|
|
|
))/oxmsg; |
11014
|
56
|
|
|
|
|
346
|
|
11015
|
56
|
50
|
33
|
|
|
183
|
# unescape character |
|
|
50
|
100
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
11016
|
|
|
|
|
|
|
for (my $i=0; $i <= $#char; $i++) { |
11017
|
|
|
|
|
|
|
if (0) { |
11018
|
|
|
|
|
|
|
} |
11019
|
56
|
|
|
|
|
738
|
|
11020
|
0
|
|
|
|
|
0
|
# escape last octet of multiple-octet |
11021
|
|
|
|
|
|
|
elsif ($char[$i] =~ /\A ([\x80-\xFF].*) ([\\|\[\{\^]|\Q$delimiter\E|\Q$end_delimiter\E) \z/xms) { |
11022
|
|
|
|
|
|
|
$char[$i] = $1 . '\\' . $2; |
11023
|
|
|
|
|
|
|
} |
11024
|
|
|
|
|
|
|
|
11025
|
0
|
|
|
|
|
0
|
# open character class [...] |
11026
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[') { |
11027
|
0
|
|
|
|
|
0
|
my $left = $i; |
11028
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
11029
|
0
|
|
|
|
|
0
|
$i++; |
11030
|
0
|
0
|
|
|
|
0
|
} |
11031
|
0
|
|
|
|
|
0
|
while (1) { |
11032
|
|
|
|
|
|
|
if (++$i > $#char) { |
11033
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11034
|
0
|
|
|
|
|
0
|
} |
11035
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11036
|
|
|
|
|
|
|
my $right = $i; |
11037
|
0
|
|
|
|
|
0
|
|
11038
|
|
|
|
|
|
|
# [...] |
11039
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Ehp15::charlist_qr(@char[$left+1..$right-1], $modifier); |
11040
|
0
|
|
|
|
|
0
|
|
11041
|
|
|
|
|
|
|
$i = $left; |
11042
|
|
|
|
|
|
|
last; |
11043
|
|
|
|
|
|
|
} |
11044
|
|
|
|
|
|
|
} |
11045
|
|
|
|
|
|
|
} |
11046
|
|
|
|
|
|
|
|
11047
|
0
|
|
|
|
|
0
|
# open character class [^...] |
11048
|
0
|
0
|
|
|
|
0
|
elsif ($char[$i] eq '[^') { |
11049
|
0
|
|
|
|
|
0
|
my $left = $i; |
11050
|
|
|
|
|
|
|
if ($char[$i+1] eq ']') { |
11051
|
0
|
|
|
|
|
0
|
$i++; |
11052
|
0
|
0
|
|
|
|
0
|
} |
11053
|
0
|
|
|
|
|
0
|
while (1) { |
11054
|
|
|
|
|
|
|
if (++$i > $#char) { |
11055
|
0
|
0
|
|
|
|
0
|
die __FILE__, ": Unmatched [] in regexp\n"; |
11056
|
0
|
|
|
|
|
0
|
} |
11057
|
|
|
|
|
|
|
if ($char[$i] eq ']') { |
11058
|
|
|
|
|
|
|
my $right = $i; |
11059
|
0
|
|
|
|
|
0
|
|
11060
|
|
|
|
|
|
|
# [^...] |
11061
|
0
|
|
|
|
|
0
|
splice @char, $left, $right-$left+1, Ehp15::charlist_not_qr(@char[$left+1..$right-1], $modifier); |
11062
|
0
|
|
|
|
|
0
|
|
11063
|
|
|
|
|
|
|
$i = $left; |
11064
|
|
|
|
|
|
|
last; |
11065
|
|
|
|
|
|
|
} |
11066
|
|
|
|
|
|
|
} |
11067
|
|
|
|
|
|
|
} |
11068
|
|
|
|
|
|
|
|
11069
|
0
|
|
|
|
|
0
|
# rewrite character class or escape character |
11070
|
|
|
|
|
|
|
elsif (my $char = character_class($char[$i],$modifier)) { |
11071
|
|
|
|
|
|
|
$char[$i] = $char; |
11072
|
|
|
|
|
|
|
} |
11073
|
|
|
|
|
|
|
|
11074
|
0
|
|
|
|
|
0
|
# split(m/^/) --> split(m/^/m) |
11075
|
|
|
|
|
|
|
elsif (($char[$i] eq '^') and ($modifier !~ /m/oxms)) { |
11076
|
|
|
|
|
|
|
$modifier .= 'm'; |
11077
|
|
|
|
|
|
|
} |
11078
|
|
|
|
|
|
|
|
11079
|
0
|
50
|
|
|
|
0
|
# /i modifier |
11080
|
12
|
|
|
|
|
27
|
elsif ($ignorecase and ($char[$i] =~ /\A [\x00-\xFF] \z/oxms) and (Ehp15::uc($char[$i]) ne Ehp15::fc($char[$i]))) { |
11081
|
|
|
|
|
|
|
if (CORE::length(Ehp15::fc($char[$i])) == 1) { |
11082
|
|
|
|
|
|
|
$char[$i] = '[' . Ehp15::uc($char[$i]) . Ehp15::fc($char[$i]) . ']'; |
11083
|
12
|
|
|
|
|
30
|
} |
11084
|
|
|
|
|
|
|
else { |
11085
|
|
|
|
|
|
|
$char[$i] = '(?:' . Ehp15::uc($char[$i]) . '|' . Ehp15::fc($char[$i]) . ')'; |
11086
|
|
|
|
|
|
|
} |
11087
|
|
|
|
|
|
|
} |
11088
|
|
|
|
|
|
|
|
11089
|
0
|
0
|
|
|
|
0
|
# quote character before ? + * { |
11090
|
|
|
|
|
|
|
elsif (($i >= 1) and ($char[$i] =~ /\A [\?\+\*\{] \z/oxms)) { |
11091
|
|
|
|
|
|
|
if ($char[$i-1] =~ /\A [\x00-\xFF] \z/oxms) { |
11092
|
0
|
|
|
|
|
0
|
} |
11093
|
|
|
|
|
|
|
else { |
11094
|
|
|
|
|
|
|
$char[$i-1] = '(?:' . $char[$i-1] . ')'; |
11095
|
|
|
|
|
|
|
} |
11096
|
|
|
|
|
|
|
} |
11097
|
0
|
|
|
|
|
0
|
} |
11098
|
56
|
|
|
|
|
112
|
|
11099
|
|
|
|
|
|
|
$modifier =~ tr/i//d; |
11100
|
|
|
|
|
|
|
return join '', 'Ehp15::split', $ope, $delimiter, @char, $end_delimiter, $modifier; |
11101
|
|
|
|
|
|
|
} |
11102
|
|
|
|
|
|
|
|
11103
|
|
|
|
|
|
|
# |
11104
|
|
|
|
|
|
|
# escape use without import |
11105
|
56
|
|
|
0
|
0
|
314
|
# |
11106
|
|
|
|
|
|
|
sub e_use_noimport { |
11107
|
0
|
|
|
|
|
|
my($module) = @_; |
11108
|
|
|
|
|
|
|
|
11109
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11110
|
0
|
|
|
|
|
|
|
11111
|
|
|
|
|
|
|
my $fh = gensym(); |
11112
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11113
|
0
|
|
|
|
|
|
|
11114
|
0
|
|
|
|
|
|
if (Ehp15::_open_r($fh, $realfilename)) { |
11115
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11116
|
|
|
|
|
|
|
my $script = <$fh>; |
11117
|
0
|
0
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11118
|
0
|
|
|
|
|
|
|
11119
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) HP15 (?>\s*) ([^\x80-\xA0\xE0-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11120
|
0
|
|
|
|
|
|
return qq; |
11121
|
|
|
|
|
|
|
} |
11122
|
|
|
|
|
|
|
last; |
11123
|
|
|
|
|
|
|
} |
11124
|
0
|
|
|
|
|
|
} |
11125
|
|
|
|
|
|
|
|
11126
|
|
|
|
|
|
|
return qq |
11127
|
|
|
|
|
|
|
} |
11128
|
|
|
|
|
|
|
|
11129
|
|
|
|
|
|
|
# |
11130
|
|
|
|
|
|
|
# escape no without unimport |
11131
|
0
|
|
|
0
|
0
|
|
# |
11132
|
|
|
|
|
|
|
sub e_no_nounimport { |
11133
|
0
|
|
|
|
|
|
my($module) = @_; |
11134
|
|
|
|
|
|
|
|
11135
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11136
|
0
|
|
|
|
|
|
|
11137
|
|
|
|
|
|
|
my $fh = gensym(); |
11138
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11139
|
0
|
|
|
|
|
|
|
11140
|
0
|
|
|
|
|
|
if (Ehp15::_open_r($fh, $realfilename)) { |
11141
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11142
|
|
|
|
|
|
|
my $script = <$fh>; |
11143
|
0
|
0
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11144
|
0
|
|
|
|
|
|
|
11145
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) HP15 (?>\s*) ([^\x80-\xA0\xE0-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11146
|
0
|
|
|
|
|
|
return qq; |
11147
|
|
|
|
|
|
|
} |
11148
|
|
|
|
|
|
|
last; |
11149
|
|
|
|
|
|
|
} |
11150
|
0
|
|
|
|
|
|
} |
11151
|
|
|
|
|
|
|
|
11152
|
|
|
|
|
|
|
return qq; |
11153
|
|
|
|
|
|
|
} |
11154
|
|
|
|
|
|
|
|
11155
|
|
|
|
|
|
|
# |
11156
|
|
|
|
|
|
|
# escape use with import no parameter |
11157
|
0
|
|
|
0
|
0
|
|
# |
11158
|
|
|
|
|
|
|
sub e_use_noparam { |
11159
|
0
|
|
|
|
|
|
my($module) = @_; |
11160
|
|
|
|
|
|
|
|
11161
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11162
|
0
|
|
|
|
|
|
|
11163
|
|
|
|
|
|
|
my $fh = gensym(); |
11164
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11165
|
0
|
|
|
|
|
|
|
11166
|
0
|
|
|
|
|
|
if (Ehp15::_open_r($fh, $realfilename)) { |
11167
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11168
|
|
|
|
|
|
|
my $script = <$fh>; |
11169
|
0
|
0
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11170
|
|
|
|
|
|
|
|
11171
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) HP15 (?>\s*) ([^\x80-\xA0\xE0-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11172
|
|
|
|
|
|
|
|
11173
|
|
|
|
|
|
|
# P.326 UNIVERSAL: The Ultimate Ancestor Class |
11174
|
|
|
|
|
|
|
# in Chapter 12: Objects |
11175
|
|
|
|
|
|
|
# of ISBN 0-596-00027-8 Programming Perl Third Edition. |
11176
|
|
|
|
|
|
|
|
11177
|
|
|
|
|
|
|
# P.435 UNIVERSAL: The Ultimate Ancestor Class |
11178
|
|
|
|
|
|
|
# in Chapter 12: Objects |
11179
|
|
|
|
|
|
|
# of ISBN 978-0-596-00492-7 Programming Perl 4th Edition. |
11180
|
|
|
|
|
|
|
|
11181
|
0
|
|
|
|
|
|
# (and so on) |
11182
|
|
|
|
|
|
|
|
11183
|
0
|
|
|
|
|
|
return qq[BEGIN { Ehp15::require '$expr'; $module->import() if $module->can('import'); }]; |
11184
|
|
|
|
|
|
|
} |
11185
|
|
|
|
|
|
|
last; |
11186
|
|
|
|
|
|
|
} |
11187
|
0
|
|
|
|
|
|
} |
11188
|
|
|
|
|
|
|
|
11189
|
|
|
|
|
|
|
return qq |
11190
|
|
|
|
|
|
|
} |
11191
|
|
|
|
|
|
|
|
11192
|
|
|
|
|
|
|
# |
11193
|
|
|
|
|
|
|
# escape no with unimport no parameter |
11194
|
0
|
|
|
0
|
0
|
|
# |
11195
|
|
|
|
|
|
|
sub e_no_noparam { |
11196
|
0
|
|
|
|
|
|
my($module) = @_; |
11197
|
|
|
|
|
|
|
|
11198
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11199
|
0
|
|
|
|
|
|
|
11200
|
|
|
|
|
|
|
my $fh = gensym(); |
11201
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11202
|
0
|
|
|
|
|
|
|
11203
|
0
|
|
|
|
|
|
if (Ehp15::_open_r($fh, $realfilename)) { |
11204
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11205
|
|
|
|
|
|
|
my $script = <$fh>; |
11206
|
0
|
0
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11207
|
0
|
|
|
|
|
|
|
11208
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) HP15 (?>\s*) ([^\x80-\xA0\xE0-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11209
|
0
|
|
|
|
|
|
return qq[BEGIN { Ehp15::require '$expr'; $module->unimport() if $module->can('unimport'); }]; |
11210
|
|
|
|
|
|
|
} |
11211
|
|
|
|
|
|
|
last; |
11212
|
|
|
|
|
|
|
} |
11213
|
0
|
|
|
|
|
|
} |
11214
|
|
|
|
|
|
|
|
11215
|
|
|
|
|
|
|
return qq; |
11216
|
|
|
|
|
|
|
} |
11217
|
|
|
|
|
|
|
|
11218
|
|
|
|
|
|
|
# |
11219
|
|
|
|
|
|
|
# escape use with import parameters |
11220
|
0
|
|
|
0
|
0
|
|
# |
11221
|
|
|
|
|
|
|
sub e_use { |
11222
|
0
|
|
|
|
|
|
my($module,$list) = @_; |
11223
|
|
|
|
|
|
|
|
11224
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11225
|
0
|
|
|
|
|
|
|
11226
|
|
|
|
|
|
|
my $fh = gensym(); |
11227
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11228
|
0
|
|
|
|
|
|
|
11229
|
0
|
|
|
|
|
|
if (Ehp15::_open_r($fh, $realfilename)) { |
11230
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11231
|
|
|
|
|
|
|
my $script = <$fh>; |
11232
|
0
|
0
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11233
|
0
|
|
|
|
|
|
|
11234
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) HP15 (?>\s*) ([^\x80-\xA0\xE0-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11235
|
0
|
|
|
|
|
|
return qq[BEGIN { Ehp15::require '$expr'; $module->import($list) if $module->can('import'); }]; |
11236
|
|
|
|
|
|
|
} |
11237
|
|
|
|
|
|
|
last; |
11238
|
|
|
|
|
|
|
} |
11239
|
0
|
|
|
|
|
|
} |
11240
|
|
|
|
|
|
|
|
11241
|
|
|
|
|
|
|
return qq |
11242
|
|
|
|
|
|
|
} |
11243
|
|
|
|
|
|
|
|
11244
|
|
|
|
|
|
|
# |
11245
|
|
|
|
|
|
|
# escape no with unimport parameters |
11246
|
0
|
|
|
0
|
0
|
|
# |
11247
|
|
|
|
|
|
|
sub e_no { |
11248
|
0
|
|
|
|
|
|
my($module,$list) = @_; |
11249
|
|
|
|
|
|
|
|
11250
|
0
|
|
|
|
|
|
my $expr = _pathof($module); |
11251
|
0
|
|
|
|
|
|
|
11252
|
|
|
|
|
|
|
my $fh = gensym(); |
11253
|
0
|
0
|
|
|
|
|
for my $realfilename (_realfilename($expr)) { |
11254
|
0
|
|
|
|
|
|
|
11255
|
0
|
|
|
|
|
|
if (Ehp15::_open_r($fh, $realfilename)) { |
11256
|
0
|
0
|
|
|
|
|
local $/ = undef; # slurp mode |
11257
|
|
|
|
|
|
|
my $script = <$fh>; |
11258
|
0
|
0
|
|
|
|
|
close($fh) or die "Can't close file: $realfilename: $!"; |
11259
|
0
|
|
|
|
|
|
|
11260
|
|
|
|
|
|
|
if ($script =~ /^ (?>\s*) use (?>\s+) HP15 (?>\s*) ([^\x80-\xA0\xE0-\xFE;]*) ; (?>\s*) \n? $/oxms) { |
11261
|
0
|
|
|
|
|
|
return qq[BEGIN { Ehp15::require '$expr'; $module->unimport($list) if $module->can('unimport'); }]; |
11262
|
|
|
|
|
|
|
} |
11263
|
|
|
|
|
|
|
last; |
11264
|
|
|
|
|
|
|
} |
11265
|
0
|
|
|
|
|
|
} |
11266
|
|
|
|
|
|
|
|
11267
|
|
|
|
|
|
|
return qq; |
11268
|
|
|
|
|
|
|
} |
11269
|
|
|
|
|
|
|
|
11270
|
|
|
|
|
|
|
# |
11271
|
|
|
|
|
|
|
# file path of module |
11272
|
0
|
|
|
0
|
|
|
# |
11273
|
|
|
|
|
|
|
sub _pathof { |
11274
|
0
|
0
|
|
|
|
|
my($expr) = @_; |
11275
|
0
|
|
|
|
|
|
|
11276
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
11277
|
|
|
|
|
|
|
$expr =~ s#::#:#g; |
11278
|
0
|
|
|
|
|
|
} |
11279
|
|
|
|
|
|
|
else { |
11280
|
0
|
0
|
|
|
|
|
$expr =~ s#::#/#g; |
11281
|
|
|
|
|
|
|
} |
11282
|
0
|
|
|
|
|
|
$expr .= '.pm' if $expr !~ / \.pm \z/oxmsi; |
11283
|
|
|
|
|
|
|
|
11284
|
|
|
|
|
|
|
return $expr; |
11285
|
|
|
|
|
|
|
} |
11286
|
|
|
|
|
|
|
|
11287
|
|
|
|
|
|
|
# |
11288
|
|
|
|
|
|
|
# real file name of module |
11289
|
0
|
|
|
0
|
|
|
# |
11290
|
|
|
|
|
|
|
sub _realfilename { |
11291
|
0
|
0
|
|
|
|
|
my($expr) = @_; |
11292
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11293
|
|
|
|
|
|
|
if ($^O eq 'MacOS') { |
11294
|
|
|
|
|
|
|
return map {"$_$expr"} @INC; |
11295
|
0
|
|
|
|
|
|
} |
|
0
|
|
|
|
|
|
|
11296
|
|
|
|
|
|
|
else { |
11297
|
|
|
|
|
|
|
return map {"$_/$expr"} @INC; |
11298
|
|
|
|
|
|
|
} |
11299
|
|
|
|
|
|
|
} |
11300
|
|
|
|
|
|
|
|
11301
|
|
|
|
|
|
|
# |
11302
|
|
|
|
|
|
|
# instead of Carp::carp |
11303
|
0
|
|
|
0
|
0
|
|
# |
11304
|
0
|
|
|
|
|
|
sub carp { |
11305
|
|
|
|
|
|
|
my($package,$filename,$line) = caller(1); |
11306
|
|
|
|
|
|
|
print STDERR "@_ at $filename line $line.\n"; |
11307
|
|
|
|
|
|
|
} |
11308
|
|
|
|
|
|
|
|
11309
|
|
|
|
|
|
|
# |
11310
|
|
|
|
|
|
|
# instead of Carp::croak |
11311
|
0
|
|
|
0
|
0
|
|
# |
11312
|
0
|
|
|
|
|
|
sub croak { |
11313
|
0
|
|
|
|
|
|
my($package,$filename,$line) = caller(1); |
11314
|
|
|
|
|
|
|
print STDERR "@_ at $filename line $line.\n"; |
11315
|
|
|
|
|
|
|
die "\n"; |
11316
|
|
|
|
|
|
|
} |
11317
|
|
|
|
|
|
|
|
11318
|
|
|
|
|
|
|
# |
11319
|
|
|
|
|
|
|
# instead of Carp::cluck |
11320
|
0
|
|
|
0
|
0
|
|
# |
11321
|
0
|
|
|
|
|
|
sub cluck { |
11322
|
0
|
|
|
|
|
|
my $i = 0; |
11323
|
0
|
|
|
|
|
|
my @cluck = (); |
11324
|
0
|
|
|
|
|
|
while (my($package,$filename,$line,$subroutine) = caller($i)) { |
11325
|
|
|
|
|
|
|
push @cluck, "[$i] $filename($line) $package::$subroutine\n"; |
11326
|
0
|
|
|
|
|
|
$i++; |
11327
|
0
|
|
|
|
|
|
} |
11328
|
0
|
|
|
|
|
|
print STDERR CORE::reverse @cluck; |
11329
|
|
|
|
|
|
|
print STDERR "\n"; |
11330
|
|
|
|
|
|
|
print STDERR @_; |
11331
|
|
|
|
|
|
|
} |
11332
|
|
|
|
|
|
|
|
11333
|
|
|
|
|
|
|
# |
11334
|
|
|
|
|
|
|
# instead of Carp::confess |
11335
|
0
|
|
|
0
|
0
|
|
# |
11336
|
0
|
|
|
|
|
|
sub confess { |
11337
|
0
|
|
|
|
|
|
my $i = 0; |
11338
|
0
|
|
|
|
|
|
my @confess = (); |
11339
|
0
|
|
|
|
|
|
while (my($package,$filename,$line,$subroutine) = caller($i)) { |
11340
|
|
|
|
|
|
|
push @confess, "[$i] $filename($line) $package::$subroutine\n"; |
11341
|
0
|
|
|
|
|
|
$i++; |
11342
|
0
|
|
|
|
|
|
} |
11343
|
0
|
|
|
|
|
|
print STDERR CORE::reverse @confess; |
11344
|
0
|
|
|
|
|
|
print STDERR "\n"; |
11345
|
|
|
|
|
|
|
print STDERR @_; |
11346
|
|
|
|
|
|
|
die "\n"; |
11347
|
|
|
|
|
|
|
} |
11348
|
|
|
|
|
|
|
|
11349
|
|
|
|
|
|
|
1; |
11350
|
|
|
|
|
|
|
|
11351
|
|
|
|
|
|
|
__END__ |