line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This file was autogenerated. |
2
|
4
|
|
|
4
|
|
231908
|
use 5.008001; |
|
4
|
|
|
|
|
21
|
|
3
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
80
|
|
4
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
122
|
|
5
|
4
|
|
|
4
|
|
20
|
no warnings qw( void once ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
112
|
|
6
|
4
|
|
|
4
|
|
419
|
use Hydrogen (); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
386
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Hydrogen::String; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
11
|
|
|
|
|
|
|
our $VERSION = '0.018'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Hydrogen::String - a standard library for strings |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This documentation is for Hydrogen::String 0.018, |
20
|
|
|
|
|
|
|
which is based on Sub::HandlesVia::HandlerLibrary::String 0.046. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 FUNCTIONS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Each function expects a string scalar as its first argument. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
28
|
use Exporter::Shiny qw( |
31
|
|
|
|
|
|
|
append |
32
|
|
|
|
|
|
|
chomp |
33
|
|
|
|
|
|
|
chop |
34
|
|
|
|
|
|
|
clear |
35
|
|
|
|
|
|
|
cmp |
36
|
|
|
|
|
|
|
cmpi |
37
|
|
|
|
|
|
|
contains |
38
|
|
|
|
|
|
|
contains_i |
39
|
|
|
|
|
|
|
ends_with |
40
|
|
|
|
|
|
|
ends_with_i |
41
|
|
|
|
|
|
|
eq |
42
|
|
|
|
|
|
|
eqi |
43
|
|
|
|
|
|
|
fc |
44
|
|
|
|
|
|
|
ge |
45
|
|
|
|
|
|
|
gei |
46
|
|
|
|
|
|
|
get |
47
|
|
|
|
|
|
|
gt |
48
|
|
|
|
|
|
|
gti |
49
|
|
|
|
|
|
|
inc |
50
|
|
|
|
|
|
|
lc |
51
|
|
|
|
|
|
|
le |
52
|
|
|
|
|
|
|
lei |
53
|
|
|
|
|
|
|
length |
54
|
|
|
|
|
|
|
lt |
55
|
|
|
|
|
|
|
lti |
56
|
|
|
|
|
|
|
match |
57
|
|
|
|
|
|
|
match_i |
58
|
|
|
|
|
|
|
ne |
59
|
|
|
|
|
|
|
nei |
60
|
|
|
|
|
|
|
prepend |
61
|
|
|
|
|
|
|
replace |
62
|
|
|
|
|
|
|
replace_globally |
63
|
|
|
|
|
|
|
reset |
64
|
|
|
|
|
|
|
set |
65
|
|
|
|
|
|
|
starts_with |
66
|
|
|
|
|
|
|
starts_with_i |
67
|
|
|
|
|
|
|
substr |
68
|
|
|
|
|
|
|
uc |
69
|
4
|
|
|
4
|
|
26
|
); |
|
4
|
|
|
|
|
10
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 C<< append( $string, $tail ) >> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Appends another string to the end of the current string and updates the original value. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub append { |
80
|
4
|
|
|
4
|
1
|
9813
|
my $__REF__ = \$_[0]; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
83
|
4
|
|
|
|
|
10
|
@_ = do { |
84
|
4
|
|
|
|
|
7
|
my ( %tmp, $tmp ); |
85
|
|
|
|
|
|
|
|
86
|
4
|
50
|
|
|
|
12
|
@_ == 2 |
87
|
|
|
|
|
|
|
or Hydrogen::croak( |
88
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
89
|
|
|
|
|
|
|
"append", scalar(@_), "expected exactly 2 parameters" ); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
92
|
4
|
50
|
|
|
|
8
|
do { |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
95
|
4
|
50
|
|
|
|
14
|
defined( $_[0] ) and do { |
96
|
4
|
50
|
|
|
|
27
|
ref( \$_[0] ) eq 'SCALAR' |
97
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
or Hydrogen::croak( |
101
|
|
|
|
|
|
|
"Type check failed in signature for append: %s should be %s", |
102
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
105
|
4
|
50
|
|
|
|
6
|
do { |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
108
|
4
|
50
|
|
|
|
14
|
defined( $_[1] ) and do { |
109
|
4
|
50
|
|
|
|
21
|
ref( \$_[1] ) eq 'SCALAR' |
110
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
or Hydrogen::croak( |
114
|
|
|
|
|
|
|
"Type check failed in signature for append: %s should be %s", |
115
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
116
|
|
|
|
|
|
|
|
117
|
4
|
|
|
|
|
15
|
(@_); |
118
|
|
|
|
|
|
|
}; |
119
|
|
|
|
|
|
|
( |
120
|
4
|
|
|
|
|
6
|
${$__REF__} = do { |
|
4
|
|
|
|
|
11
|
|
121
|
4
|
|
|
|
|
10
|
my $shv_final_unchecked = $$__REF__ . $_[1]; |
122
|
4
|
|
|
|
|
15
|
do { |
123
|
4
|
50
|
|
|
|
9
|
do { |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
126
|
4
|
50
|
|
|
|
13
|
defined($shv_final_unchecked) and do { |
127
|
4
|
50
|
|
|
|
19
|
ref( \$shv_final_unchecked ) eq 'SCALAR' |
128
|
|
|
|
|
|
|
or ref( \( my $val = $shv_final_unchecked ) ) eq |
129
|
|
|
|
|
|
|
'SCALAR'; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
or Hydrogen::croak( |
133
|
|
|
|
|
|
|
"Type check failed for append: expected %s, got value %s", |
134
|
|
|
|
|
|
|
"Str", $shv_final_unchecked ); |
135
|
4
|
|
|
|
|
9
|
$shv_final_unchecked; |
136
|
|
|
|
|
|
|
}; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 C<< chomp( $string ) >> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Like C from L. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub chomp { |
148
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
151
|
0
|
0
|
|
|
|
0
|
@_ == 1 |
152
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for chomp; usage: " |
153
|
|
|
|
|
|
|
. "Hydrogen::String::chomp( \$string )" ); |
154
|
0
|
|
|
|
|
0
|
1; |
155
|
0
|
|
|
|
|
0
|
chomp($$__REF__); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 C<< chop( $string ) >> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Like C from L. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub chop { |
165
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
168
|
0
|
0
|
|
|
|
0
|
@_ == 1 |
169
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for chop; usage: " |
170
|
|
|
|
|
|
|
. "Hydrogen::String::chop( \$string )" ); |
171
|
0
|
|
|
|
|
0
|
1; |
172
|
0
|
|
|
|
|
0
|
chop($$__REF__); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 C<< clear( $string ) >> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Sets the string to the empty string. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub clear { |
182
|
1
|
|
|
1
|
1
|
8901
|
my $__REF__ = \$_[0]; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
185
|
1
|
50
|
|
|
|
5
|
@_ == 1 |
186
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for clear; usage: " |
187
|
|
|
|
|
|
|
. "Hydrogen::String::clear( \$string )" ); |
188
|
1
|
|
|
|
|
4
|
1; |
189
|
1
|
|
|
|
|
4
|
( ${$__REF__} = q() ); |
|
1
|
|
|
|
|
3
|
|
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 C<< cmp( $string, $str ) >> |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Returns C<< $string cmp $str >>. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub cmp { |
201
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
204
|
0
|
|
|
|
|
0
|
@_ = do { |
205
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
206
|
|
|
|
|
|
|
|
207
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
208
|
|
|
|
|
|
|
or Hydrogen::croak( |
209
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
210
|
|
|
|
|
|
|
"cmp", scalar(@_), "expected exactly 2 parameters" ); |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
213
|
0
|
0
|
|
|
|
0
|
do { |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
216
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
217
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
218
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
or Hydrogen::croak( |
222
|
|
|
|
|
|
|
"Type check failed in signature for cmp: %s should be %s", |
223
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
226
|
0
|
0
|
|
|
|
0
|
do { |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
229
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
230
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
231
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
or Hydrogen::croak( |
235
|
|
|
|
|
|
|
"Type check failed in signature for cmp: %s should be %s", |
236
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
237
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
0
|
(@_); |
239
|
|
|
|
|
|
|
}; |
240
|
0
|
|
|
|
|
0
|
$$__REF__ cmp $_[1]; |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 C<< cmpi( $string, $str ) >> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Returns C<< fc($string) cmp fc($str) >>. Uses C instead of C in versions of Perl older than 5.16. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub cmpi { |
252
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
255
|
0
|
|
|
|
|
0
|
@_ = do { |
256
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
257
|
|
|
|
|
|
|
|
258
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
259
|
|
|
|
|
|
|
or Hydrogen::croak( |
260
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
261
|
|
|
|
|
|
|
"cmpi", scalar(@_), "expected exactly 2 parameters" ); |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
264
|
0
|
0
|
|
|
|
0
|
do { |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
267
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
268
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
269
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
or Hydrogen::croak( |
273
|
|
|
|
|
|
|
"Type check failed in signature for cmpi: %s should be %s", |
274
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
277
|
0
|
0
|
|
|
|
0
|
do { |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
280
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
281
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
282
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
or Hydrogen::croak( |
286
|
|
|
|
|
|
|
"Type check failed in signature for cmpi: %s should be %s", |
287
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
288
|
|
|
|
|
|
|
|
289
|
0
|
|
|
|
|
0
|
(@_); |
290
|
|
|
|
|
|
|
}; |
291
|
0
|
|
|
|
|
0
|
Hydrogen::fc($$__REF__) cmp Hydrogen::fc( $_[1] ); |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head2 C<< contains( $string, $str ) >> |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Returns true iff the string contains C<< $str >>. |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=cut |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub contains { |
303
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
306
|
0
|
|
|
|
|
0
|
@_ = do { |
307
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
308
|
|
|
|
|
|
|
|
309
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
310
|
|
|
|
|
|
|
or Hydrogen::croak( |
311
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
312
|
|
|
|
|
|
|
"contains", scalar(@_), "expected exactly 2 parameters" ); |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
315
|
0
|
0
|
|
|
|
0
|
do { |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
318
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
319
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
320
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
or Hydrogen::croak( |
324
|
|
|
|
|
|
|
"Type check failed in signature for contains: %s should be %s", |
325
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
328
|
0
|
0
|
|
|
|
0
|
do { |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
331
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
332
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
333
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
or Hydrogen::croak( |
337
|
|
|
|
|
|
|
"Type check failed in signature for contains: %s should be %s", |
338
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
339
|
|
|
|
|
|
|
|
340
|
0
|
|
|
|
|
0
|
(@_); |
341
|
|
|
|
|
|
|
}; |
342
|
0
|
|
|
|
|
0
|
index( $$__REF__, $_[1] ) != -1; |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
=head2 C<< contains_i( $string, $str ) >> |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
Returns true iff the string contains C<< $str >> case-insensitvely. |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=cut |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
sub contains_i { |
354
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
357
|
0
|
|
|
|
|
0
|
@_ = do { |
358
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
359
|
|
|
|
|
|
|
|
360
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
361
|
|
|
|
|
|
|
or Hydrogen::croak( |
362
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
363
|
|
|
|
|
|
|
"contains_i", scalar(@_), "expected exactly 2 parameters" ); |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
366
|
0
|
0
|
|
|
|
0
|
do { |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
369
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
370
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
371
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
or Hydrogen::croak( |
375
|
|
|
|
|
|
|
"Type check failed in signature for contains_i: %s should be %s", |
376
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
379
|
0
|
0
|
|
|
|
0
|
do { |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
382
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
383
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
384
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
385
|
|
|
|
|
|
|
} |
386
|
|
|
|
|
|
|
} |
387
|
|
|
|
|
|
|
or Hydrogen::croak( |
388
|
|
|
|
|
|
|
"Type check failed in signature for contains_i: %s should be %s", |
389
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
390
|
|
|
|
|
|
|
|
391
|
0
|
|
|
|
|
0
|
(@_); |
392
|
|
|
|
|
|
|
}; |
393
|
0
|
|
|
|
|
0
|
index( Hydrogen::fc($$__REF__), Hydrogen::fc( $_[1] ) ) != -1; |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=head2 C<< ends_with( $string, $tail ) >> |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
Returns true iff the string ends with C<< $tail >>. |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=cut |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
sub ends_with { |
405
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
408
|
0
|
|
|
|
|
0
|
@_ = do { |
409
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
410
|
|
|
|
|
|
|
|
411
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
412
|
|
|
|
|
|
|
or Hydrogen::croak( |
413
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
414
|
|
|
|
|
|
|
"ends_with", scalar(@_), "expected exactly 2 parameters" ); |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
417
|
0
|
0
|
|
|
|
0
|
do { |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
420
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
421
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
422
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
423
|
|
|
|
|
|
|
} |
424
|
|
|
|
|
|
|
} |
425
|
|
|
|
|
|
|
or Hydrogen::croak( |
426
|
|
|
|
|
|
|
"Type check failed in signature for ends_with: %s should be %s", |
427
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
430
|
0
|
0
|
|
|
|
0
|
do { |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
433
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
434
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
435
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
or Hydrogen::croak( |
439
|
|
|
|
|
|
|
"Type check failed in signature for ends_with: %s should be %s", |
440
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
441
|
|
|
|
|
|
|
|
442
|
0
|
|
|
|
|
0
|
(@_); |
443
|
|
|
|
|
|
|
}; |
444
|
0
|
|
|
|
|
0
|
substr( $$__REF__, -length $_[1] ) eq $_[1]; |
445
|
|
|
|
|
|
|
} |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=head2 C<< ends_with_i( $string, $tail ) >> |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
Returns true iff the string ends with C<< $tail >> case-insensitvely. |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=cut |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
sub ends_with_i { |
456
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
459
|
0
|
|
|
|
|
0
|
@_ = do { |
460
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
461
|
|
|
|
|
|
|
|
462
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
463
|
|
|
|
|
|
|
or Hydrogen::croak( |
464
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
465
|
|
|
|
|
|
|
"ends_with_i", scalar(@_), "expected exactly 2 parameters" ); |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
468
|
0
|
0
|
|
|
|
0
|
do { |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
471
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
472
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
473
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
} |
476
|
|
|
|
|
|
|
or Hydrogen::croak( |
477
|
|
|
|
|
|
|
"Type check failed in signature for ends_with_i: %s should be %s", |
478
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
481
|
0
|
0
|
|
|
|
0
|
do { |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
484
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
485
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
486
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
or Hydrogen::croak( |
490
|
|
|
|
|
|
|
"Type check failed in signature for ends_with_i: %s should be %s", |
491
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
492
|
|
|
|
|
|
|
|
493
|
0
|
|
|
|
|
0
|
(@_); |
494
|
|
|
|
|
|
|
}; |
495
|
0
|
|
|
|
|
0
|
Hydrogen::fc( substr( $$__REF__, -length $_[1] ) ) eq Hydrogen::fc( $_[1] ); |
496
|
|
|
|
|
|
|
} |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=head2 C<< eq( $string, $str ) >> |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
Returns C<< $string eq $str >>. |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=cut |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
sub eq { |
507
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
510
|
0
|
|
|
|
|
0
|
@_ = do { |
511
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
512
|
|
|
|
|
|
|
|
513
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
514
|
|
|
|
|
|
|
or Hydrogen::croak( |
515
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
516
|
|
|
|
|
|
|
"eq", scalar(@_), "expected exactly 2 parameters" ); |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
519
|
0
|
0
|
|
|
|
0
|
do { |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
522
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
523
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
524
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
525
|
|
|
|
|
|
|
} |
526
|
|
|
|
|
|
|
} |
527
|
|
|
|
|
|
|
or Hydrogen::croak( |
528
|
|
|
|
|
|
|
"Type check failed in signature for eq: %s should be %s", |
529
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
532
|
0
|
0
|
|
|
|
0
|
do { |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
535
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
536
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
537
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
538
|
|
|
|
|
|
|
} |
539
|
|
|
|
|
|
|
} |
540
|
|
|
|
|
|
|
or Hydrogen::croak( |
541
|
|
|
|
|
|
|
"Type check failed in signature for eq: %s should be %s", |
542
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
543
|
|
|
|
|
|
|
|
544
|
0
|
|
|
|
|
0
|
(@_); |
545
|
|
|
|
|
|
|
}; |
546
|
0
|
|
|
|
|
0
|
$$__REF__ eq $_[1]; |
547
|
|
|
|
|
|
|
} |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=head2 C<< eqi( $string, $str ) >> |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
Returns C<< fc($string) eq fc($str) >>. Uses C instead of C in versions of Perl older than 5.16. |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=cut |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
sub eqi { |
558
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
561
|
0
|
|
|
|
|
0
|
@_ = do { |
562
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
563
|
|
|
|
|
|
|
|
564
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
565
|
|
|
|
|
|
|
or Hydrogen::croak( |
566
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
567
|
|
|
|
|
|
|
"eqi", scalar(@_), "expected exactly 2 parameters" ); |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
570
|
0
|
0
|
|
|
|
0
|
do { |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
573
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
574
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
575
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
576
|
|
|
|
|
|
|
} |
577
|
|
|
|
|
|
|
} |
578
|
|
|
|
|
|
|
or Hydrogen::croak( |
579
|
|
|
|
|
|
|
"Type check failed in signature for eqi: %s should be %s", |
580
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
583
|
0
|
0
|
|
|
|
0
|
do { |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
586
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
587
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
588
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
589
|
|
|
|
|
|
|
} |
590
|
|
|
|
|
|
|
} |
591
|
|
|
|
|
|
|
or Hydrogen::croak( |
592
|
|
|
|
|
|
|
"Type check failed in signature for eqi: %s should be %s", |
593
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
594
|
|
|
|
|
|
|
|
595
|
0
|
|
|
|
|
0
|
(@_); |
596
|
|
|
|
|
|
|
}; |
597
|
0
|
|
|
|
|
0
|
Hydrogen::fc($$__REF__) eq Hydrogen::fc( $_[1] ); |
598
|
|
|
|
|
|
|
} |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
=head2 C<< fc( $string ) >> |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
Returns C<< fc($string) >>. |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
=cut |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
sub fc { |
607
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
610
|
0
|
0
|
|
|
|
0
|
@_ == 1 |
611
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for fc; usage: " |
612
|
|
|
|
|
|
|
. "Hydrogen::String::fc( \$string )" ); |
613
|
0
|
|
|
|
|
0
|
Hydrogen::fc($$__REF__); |
614
|
|
|
|
|
|
|
} |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
=head2 C<< ge( $string, $str ) >> |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
Returns C<< $string ge $str >>. |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
=cut |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
sub ge { |
625
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
628
|
0
|
|
|
|
|
0
|
@_ = do { |
629
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
630
|
|
|
|
|
|
|
|
631
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
632
|
|
|
|
|
|
|
or Hydrogen::croak( |
633
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
634
|
|
|
|
|
|
|
"ge", scalar(@_), "expected exactly 2 parameters" ); |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
637
|
0
|
0
|
|
|
|
0
|
do { |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
640
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
641
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
642
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
643
|
|
|
|
|
|
|
} |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
or Hydrogen::croak( |
646
|
|
|
|
|
|
|
"Type check failed in signature for ge: %s should be %s", |
647
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
650
|
0
|
0
|
|
|
|
0
|
do { |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
653
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
654
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
655
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
656
|
|
|
|
|
|
|
} |
657
|
|
|
|
|
|
|
} |
658
|
|
|
|
|
|
|
or Hydrogen::croak( |
659
|
|
|
|
|
|
|
"Type check failed in signature for ge: %s should be %s", |
660
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
661
|
|
|
|
|
|
|
|
662
|
0
|
|
|
|
|
0
|
(@_); |
663
|
|
|
|
|
|
|
}; |
664
|
0
|
|
|
|
|
0
|
$$__REF__ ge $_[1]; |
665
|
|
|
|
|
|
|
} |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
=head2 C<< gei( $string, $str ) >> |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
Returns C<< fc($string) ge fc($str) >>. Uses C instead of C in versions of Perl older than 5.16. |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
=cut |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
sub gei { |
676
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
679
|
0
|
|
|
|
|
0
|
@_ = do { |
680
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
681
|
|
|
|
|
|
|
|
682
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
683
|
|
|
|
|
|
|
or Hydrogen::croak( |
684
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
685
|
|
|
|
|
|
|
"gei", scalar(@_), "expected exactly 2 parameters" ); |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
688
|
0
|
0
|
|
|
|
0
|
do { |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
691
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
692
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
693
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
694
|
|
|
|
|
|
|
} |
695
|
|
|
|
|
|
|
} |
696
|
|
|
|
|
|
|
or Hydrogen::croak( |
697
|
|
|
|
|
|
|
"Type check failed in signature for gei: %s should be %s", |
698
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
701
|
0
|
0
|
|
|
|
0
|
do { |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
704
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
705
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
706
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
707
|
|
|
|
|
|
|
} |
708
|
|
|
|
|
|
|
} |
709
|
|
|
|
|
|
|
or Hydrogen::croak( |
710
|
|
|
|
|
|
|
"Type check failed in signature for gei: %s should be %s", |
711
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
712
|
|
|
|
|
|
|
|
713
|
0
|
|
|
|
|
0
|
(@_); |
714
|
|
|
|
|
|
|
}; |
715
|
0
|
|
|
|
|
0
|
Hydrogen::fc($$__REF__) ge Hydrogen::fc( $_[1] ); |
716
|
|
|
|
|
|
|
} |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
=head2 C<< get( $string ) >> |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
Gets the current value of the string. |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
=cut |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
sub get { |
725
|
1
|
|
|
1
|
1
|
29767
|
my $__REF__ = \$_[0]; |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
728
|
1
|
50
|
|
|
|
7
|
@_ == 1 |
729
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for get; usage: " |
730
|
|
|
|
|
|
|
. "Hydrogen::String::get( \$string )" ); |
731
|
1
|
|
|
|
|
10
|
$$__REF__; |
732
|
|
|
|
|
|
|
} |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
=head2 C<< gt( $string, $str ) >> |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
Returns C<< $string gt $str >>. |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
=cut |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
sub gt { |
743
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
746
|
0
|
|
|
|
|
0
|
@_ = do { |
747
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
748
|
|
|
|
|
|
|
|
749
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
750
|
|
|
|
|
|
|
or Hydrogen::croak( |
751
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
752
|
|
|
|
|
|
|
"gt", scalar(@_), "expected exactly 2 parameters" ); |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
755
|
0
|
0
|
|
|
|
0
|
do { |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
758
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
759
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
760
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
761
|
|
|
|
|
|
|
} |
762
|
|
|
|
|
|
|
} |
763
|
|
|
|
|
|
|
or Hydrogen::croak( |
764
|
|
|
|
|
|
|
"Type check failed in signature for gt: %s should be %s", |
765
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
766
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
768
|
0
|
0
|
|
|
|
0
|
do { |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
771
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
772
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
773
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
774
|
|
|
|
|
|
|
} |
775
|
|
|
|
|
|
|
} |
776
|
|
|
|
|
|
|
or Hydrogen::croak( |
777
|
|
|
|
|
|
|
"Type check failed in signature for gt: %s should be %s", |
778
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
779
|
|
|
|
|
|
|
|
780
|
0
|
|
|
|
|
0
|
(@_); |
781
|
|
|
|
|
|
|
}; |
782
|
0
|
|
|
|
|
0
|
$$__REF__ gt $_[1]; |
783
|
|
|
|
|
|
|
} |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
=head2 C<< gti( $string, $str ) >> |
786
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
Returns C<< fc($string) gt fc($str) >>. Uses C instead of C in versions of Perl older than 5.16. |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
=cut |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
sub gti { |
794
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
797
|
0
|
|
|
|
|
0
|
@_ = do { |
798
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
799
|
|
|
|
|
|
|
|
800
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
801
|
|
|
|
|
|
|
or Hydrogen::croak( |
802
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
803
|
|
|
|
|
|
|
"gti", scalar(@_), "expected exactly 2 parameters" ); |
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
806
|
0
|
0
|
|
|
|
0
|
do { |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
809
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
810
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
811
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
812
|
|
|
|
|
|
|
} |
813
|
|
|
|
|
|
|
} |
814
|
|
|
|
|
|
|
or Hydrogen::croak( |
815
|
|
|
|
|
|
|
"Type check failed in signature for gti: %s should be %s", |
816
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
819
|
0
|
0
|
|
|
|
0
|
do { |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
822
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
823
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
824
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
825
|
|
|
|
|
|
|
} |
826
|
|
|
|
|
|
|
} |
827
|
|
|
|
|
|
|
or Hydrogen::croak( |
828
|
|
|
|
|
|
|
"Type check failed in signature for gti: %s should be %s", |
829
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
830
|
|
|
|
|
|
|
|
831
|
0
|
|
|
|
|
0
|
(@_); |
832
|
|
|
|
|
|
|
}; |
833
|
0
|
|
|
|
|
0
|
Hydrogen::fc($$__REF__) gt Hydrogen::fc( $_[1] ); |
834
|
|
|
|
|
|
|
} |
835
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
=head2 C<< inc( $string ) >> |
837
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
Performs C<< ++ >> on the string. |
839
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
=cut |
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
sub inc { |
843
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
844
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
846
|
0
|
0
|
|
|
|
0
|
@_ == 1 |
847
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for inc; usage: " |
848
|
|
|
|
|
|
|
. "Hydrogen::String::inc( \$string )" ); |
849
|
0
|
|
|
|
|
0
|
1; |
850
|
0
|
|
|
|
|
0
|
++$$__REF__; |
851
|
|
|
|
|
|
|
} |
852
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
=head2 C<< lc( $string ) >> |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
Returns C<< lc($string) >>. |
856
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
=cut |
858
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
sub lc { |
860
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
861
|
|
|
|
|
|
|
|
862
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
863
|
0
|
0
|
|
|
|
0
|
@_ == 1 |
864
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for lc; usage: " |
865
|
|
|
|
|
|
|
. "Hydrogen::String::lc( \$string )" ); |
866
|
0
|
|
|
|
|
0
|
lc($$__REF__); |
867
|
|
|
|
|
|
|
} |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
=head2 C<< le( $string, $str ) >> |
870
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
Returns C<< $string le $str >>. |
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
=cut |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
sub le { |
878
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
879
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
881
|
0
|
|
|
|
|
0
|
@_ = do { |
882
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
883
|
|
|
|
|
|
|
|
884
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
885
|
|
|
|
|
|
|
or Hydrogen::croak( |
886
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
887
|
|
|
|
|
|
|
"le", scalar(@_), "expected exactly 2 parameters" ); |
888
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
890
|
0
|
0
|
|
|
|
0
|
do { |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
893
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
894
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
895
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
896
|
|
|
|
|
|
|
} |
897
|
|
|
|
|
|
|
} |
898
|
|
|
|
|
|
|
or Hydrogen::croak( |
899
|
|
|
|
|
|
|
"Type check failed in signature for le: %s should be %s", |
900
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
903
|
0
|
0
|
|
|
|
0
|
do { |
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
906
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
907
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
908
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
909
|
|
|
|
|
|
|
} |
910
|
|
|
|
|
|
|
} |
911
|
|
|
|
|
|
|
or Hydrogen::croak( |
912
|
|
|
|
|
|
|
"Type check failed in signature for le: %s should be %s", |
913
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
914
|
|
|
|
|
|
|
|
915
|
0
|
|
|
|
|
0
|
(@_); |
916
|
|
|
|
|
|
|
}; |
917
|
0
|
|
|
|
|
0
|
$$__REF__ le $_[1]; |
918
|
|
|
|
|
|
|
} |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
=head2 C<< lei( $string, $str ) >> |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
Returns C<< fc($string) le fc($str) >>. Uses C instead of C in versions of Perl older than 5.16. |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
=cut |
927
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
sub lei { |
929
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
930
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
932
|
0
|
|
|
|
|
0
|
@_ = do { |
933
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
934
|
|
|
|
|
|
|
|
935
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
936
|
|
|
|
|
|
|
or Hydrogen::croak( |
937
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
938
|
|
|
|
|
|
|
"lei", scalar(@_), "expected exactly 2 parameters" ); |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
941
|
0
|
0
|
|
|
|
0
|
do { |
942
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
944
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
945
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
946
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
947
|
|
|
|
|
|
|
} |
948
|
|
|
|
|
|
|
} |
949
|
|
|
|
|
|
|
or Hydrogen::croak( |
950
|
|
|
|
|
|
|
"Type check failed in signature for lei: %s should be %s", |
951
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
952
|
|
|
|
|
|
|
|
953
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
954
|
0
|
0
|
|
|
|
0
|
do { |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
957
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
958
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
959
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
960
|
|
|
|
|
|
|
} |
961
|
|
|
|
|
|
|
} |
962
|
|
|
|
|
|
|
or Hydrogen::croak( |
963
|
|
|
|
|
|
|
"Type check failed in signature for lei: %s should be %s", |
964
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
965
|
|
|
|
|
|
|
|
966
|
0
|
|
|
|
|
0
|
(@_); |
967
|
|
|
|
|
|
|
}; |
968
|
0
|
|
|
|
|
0
|
Hydrogen::fc($$__REF__) le Hydrogen::fc( $_[1] ); |
969
|
|
|
|
|
|
|
} |
970
|
|
|
|
|
|
|
|
971
|
|
|
|
|
|
|
=head2 C<< length( $string ) >> |
972
|
|
|
|
|
|
|
|
973
|
|
|
|
|
|
|
Like C from L. |
974
|
|
|
|
|
|
|
|
975
|
|
|
|
|
|
|
=cut |
976
|
|
|
|
|
|
|
|
977
|
|
|
|
|
|
|
sub length { |
978
|
1
|
|
|
1
|
1
|
20614
|
my $__REF__ = \$_[0]; |
979
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
981
|
1
|
50
|
|
|
|
8
|
@_ == 1 |
982
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for length; usage: " |
983
|
|
|
|
|
|
|
. "Hydrogen::String::length( \$string )" ); |
984
|
1
|
|
|
|
|
31
|
length($$__REF__); |
985
|
|
|
|
|
|
|
} |
986
|
|
|
|
|
|
|
|
987
|
|
|
|
|
|
|
=head2 C<< lt( $string, $str ) >> |
988
|
|
|
|
|
|
|
|
989
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
990
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
Returns C<< $string lt $str >>. |
992
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
=cut |
994
|
|
|
|
|
|
|
|
995
|
|
|
|
|
|
|
sub lt { |
996
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
999
|
0
|
|
|
|
|
0
|
@_ = do { |
1000
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
1001
|
|
|
|
|
|
|
|
1002
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
1003
|
|
|
|
|
|
|
or Hydrogen::croak( |
1004
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1005
|
|
|
|
|
|
|
"lt", scalar(@_), "expected exactly 2 parameters" ); |
1006
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1008
|
0
|
0
|
|
|
|
0
|
do { |
1009
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1011
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
1012
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
1013
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1014
|
|
|
|
|
|
|
} |
1015
|
|
|
|
|
|
|
} |
1016
|
|
|
|
|
|
|
or Hydrogen::croak( |
1017
|
|
|
|
|
|
|
"Type check failed in signature for lt: %s should be %s", |
1018
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1019
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
1021
|
0
|
0
|
|
|
|
0
|
do { |
1022
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1024
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
1025
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
1026
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1027
|
|
|
|
|
|
|
} |
1028
|
|
|
|
|
|
|
} |
1029
|
|
|
|
|
|
|
or Hydrogen::croak( |
1030
|
|
|
|
|
|
|
"Type check failed in signature for lt: %s should be %s", |
1031
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
1032
|
|
|
|
|
|
|
|
1033
|
0
|
|
|
|
|
0
|
(@_); |
1034
|
|
|
|
|
|
|
}; |
1035
|
0
|
|
|
|
|
0
|
$$__REF__ lt $_[1]; |
1036
|
|
|
|
|
|
|
} |
1037
|
|
|
|
|
|
|
|
1038
|
|
|
|
|
|
|
=head2 C<< lti( $string, $str ) >> |
1039
|
|
|
|
|
|
|
|
1040
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
1041
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
Returns C<< fc($string) lt fc($str) >>. Uses C instead of C in versions of Perl older than 5.16. |
1043
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
=cut |
1045
|
|
|
|
|
|
|
|
1046
|
|
|
|
|
|
|
sub lti { |
1047
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1050
|
0
|
|
|
|
|
0
|
@_ = do { |
1051
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
1052
|
|
|
|
|
|
|
|
1053
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
1054
|
|
|
|
|
|
|
or Hydrogen::croak( |
1055
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1056
|
|
|
|
|
|
|
"lti", scalar(@_), "expected exactly 2 parameters" ); |
1057
|
|
|
|
|
|
|
|
1058
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1059
|
0
|
0
|
|
|
|
0
|
do { |
1060
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1062
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
1063
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
1064
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1065
|
|
|
|
|
|
|
} |
1066
|
|
|
|
|
|
|
} |
1067
|
|
|
|
|
|
|
or Hydrogen::croak( |
1068
|
|
|
|
|
|
|
"Type check failed in signature for lti: %s should be %s", |
1069
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1070
|
|
|
|
|
|
|
|
1071
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
1072
|
0
|
0
|
|
|
|
0
|
do { |
1073
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1075
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
1076
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
1077
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1078
|
|
|
|
|
|
|
} |
1079
|
|
|
|
|
|
|
} |
1080
|
|
|
|
|
|
|
or Hydrogen::croak( |
1081
|
|
|
|
|
|
|
"Type check failed in signature for lti: %s should be %s", |
1082
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
1083
|
|
|
|
|
|
|
|
1084
|
0
|
|
|
|
|
0
|
(@_); |
1085
|
|
|
|
|
|
|
}; |
1086
|
0
|
|
|
|
|
0
|
Hydrogen::fc($$__REF__) lt Hydrogen::fc( $_[1] ); |
1087
|
|
|
|
|
|
|
} |
1088
|
|
|
|
|
|
|
|
1089
|
|
|
|
|
|
|
=head2 C<< match( $string, $regexp ) >> |
1090
|
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
Additional arguments: B<< Str|RegexpRef >>. |
1092
|
|
|
|
|
|
|
|
1093
|
|
|
|
|
|
|
Returns true iff the string matches the regexp. |
1094
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
=cut |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
sub match { |
1098
|
1
|
|
|
1
|
1
|
9661
|
my $__REF__ = \$_[0]; |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1101
|
1
|
|
|
|
|
3
|
@_ = do { |
1102
|
1
|
|
|
|
|
3
|
my ( %tmp, $tmp ); |
1103
|
|
|
|
|
|
|
|
1104
|
1
|
50
|
|
|
|
6
|
@_ == 2 |
1105
|
|
|
|
|
|
|
or Hydrogen::croak( |
1106
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1107
|
|
|
|
|
|
|
"match", scalar(@_), "expected exactly 2 parameters" ); |
1108
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1110
|
1
|
50
|
|
|
|
3
|
do { |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1113
|
1
|
50
|
|
|
|
6
|
defined( $_[0] ) and do { |
1114
|
1
|
50
|
|
|
|
11
|
ref( \$_[0] ) eq 'SCALAR' |
1115
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1116
|
|
|
|
|
|
|
} |
1117
|
|
|
|
|
|
|
} |
1118
|
|
|
|
|
|
|
or Hydrogen::croak( |
1119
|
|
|
|
|
|
|
"Type check failed in signature for match: %s should be %s", |
1120
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str|RegexpRef) |
1123
|
1
|
50
|
|
|
|
3
|
do { |
1124
|
|
|
|
|
|
|
|
1125
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1126
|
|
|
|
|
|
|
( |
1127
|
|
|
|
|
|
|
do { |
1128
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1130
|
1
|
50
|
|
|
|
5
|
defined( $_[1] ) and do { |
1131
|
1
|
50
|
|
|
|
9
|
ref( \$_[1] ) eq 'SCALAR' |
1132
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1133
|
|
|
|
|
|
|
} |
1134
|
|
|
|
|
|
|
} |
1135
|
|
|
|
|
|
|
or ( |
1136
|
1
|
50
|
|
|
|
3
|
do { |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1139
|
4
|
|
|
4
|
|
17181
|
use Scalar::Util (); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
76
|
|
1140
|
4
|
|
|
4
|
|
41
|
use re (); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1142
|
|
1141
|
0
|
0
|
0
|
|
|
0
|
ref( $_[1] ) && !!re::is_regexp( $_[1] ) |
|
|
|
0
|
|
|
|
|
1142
|
|
|
|
|
|
|
or Scalar::Util::blessed( $_[1] ) |
1143
|
|
|
|
|
|
|
&& $_[1]->isa('Regexp'); |
1144
|
|
|
|
|
|
|
} |
1145
|
|
|
|
|
|
|
) |
1146
|
|
|
|
|
|
|
); |
1147
|
|
|
|
|
|
|
} |
1148
|
|
|
|
|
|
|
or Hydrogen::croak( |
1149
|
|
|
|
|
|
|
"Type check failed in signature for match: %s should be %s", |
1150
|
|
|
|
|
|
|
"\$_[1]", "Str|RegexpRef" ); |
1151
|
|
|
|
|
|
|
|
1152
|
1
|
|
|
|
|
8
|
(@_); |
1153
|
|
|
|
|
|
|
}; |
1154
|
1
|
|
|
|
|
34
|
$$__REF__ =~ /$_[1]/; |
1155
|
|
|
|
|
|
|
} |
1156
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
=head2 C<< match_i( $string, $regexp ) >> |
1158
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
Additional arguments: B<< Str|RegexpRef >>. |
1160
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
Returns true iff the string matches the regexp case-insensitively. |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
=cut |
1164
|
|
|
|
|
|
|
|
1165
|
|
|
|
|
|
|
sub match_i { |
1166
|
1
|
|
|
1
|
1
|
3719
|
my $__REF__ = \$_[0]; |
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1169
|
1
|
|
|
|
|
3
|
@_ = do { |
1170
|
1
|
|
|
|
|
3
|
my ( %tmp, $tmp ); |
1171
|
|
|
|
|
|
|
|
1172
|
1
|
50
|
|
|
|
8
|
@_ == 2 |
1173
|
|
|
|
|
|
|
or Hydrogen::croak( |
1174
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1175
|
|
|
|
|
|
|
"match_i", scalar(@_), "expected exactly 2 parameters" ); |
1176
|
|
|
|
|
|
|
|
1177
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1178
|
1
|
50
|
|
|
|
2
|
do { |
1179
|
|
|
|
|
|
|
|
1180
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1181
|
1
|
50
|
|
|
|
4
|
defined( $_[0] ) and do { |
1182
|
1
|
50
|
|
|
|
8
|
ref( \$_[0] ) eq 'SCALAR' |
1183
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1184
|
|
|
|
|
|
|
} |
1185
|
|
|
|
|
|
|
} |
1186
|
|
|
|
|
|
|
or Hydrogen::croak( |
1187
|
|
|
|
|
|
|
"Type check failed in signature for match_i: %s should be %s", |
1188
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str|RegexpRef) |
1191
|
1
|
50
|
|
|
|
13
|
do { |
1192
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1194
|
|
|
|
|
|
|
( |
1195
|
|
|
|
|
|
|
do { |
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1198
|
1
|
50
|
|
|
|
6
|
defined( $_[1] ) and do { |
1199
|
1
|
50
|
|
|
|
9
|
ref( \$_[1] ) eq 'SCALAR' |
1200
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1201
|
|
|
|
|
|
|
} |
1202
|
|
|
|
|
|
|
} |
1203
|
|
|
|
|
|
|
or ( |
1204
|
1
|
50
|
|
|
|
2
|
do { |
1205
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1207
|
4
|
|
|
4
|
|
35
|
use Scalar::Util (); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
109
|
|
1208
|
4
|
|
|
4
|
|
36
|
use re (); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
3748
|
|
1209
|
0
|
0
|
0
|
|
|
0
|
ref( $_[1] ) && !!re::is_regexp( $_[1] ) |
|
|
|
0
|
|
|
|
|
1210
|
|
|
|
|
|
|
or Scalar::Util::blessed( $_[1] ) |
1211
|
|
|
|
|
|
|
&& $_[1]->isa('Regexp'); |
1212
|
|
|
|
|
|
|
} |
1213
|
|
|
|
|
|
|
) |
1214
|
|
|
|
|
|
|
); |
1215
|
|
|
|
|
|
|
} |
1216
|
|
|
|
|
|
|
or Hydrogen::croak( |
1217
|
|
|
|
|
|
|
"Type check failed in signature for match_i: %s should be %s", |
1218
|
|
|
|
|
|
|
"\$_[1]", "Str|RegexpRef" ); |
1219
|
|
|
|
|
|
|
|
1220
|
1
|
|
|
|
|
5
|
(@_); |
1221
|
|
|
|
|
|
|
}; |
1222
|
1
|
|
|
|
|
17
|
$$__REF__ =~ /$_[1]/i; |
1223
|
|
|
|
|
|
|
} |
1224
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
=head2 C<< ne( $string, $str ) >> |
1226
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
Returns C<< $string ne $str >>. |
1230
|
|
|
|
|
|
|
|
1231
|
|
|
|
|
|
|
=cut |
1232
|
|
|
|
|
|
|
|
1233
|
|
|
|
|
|
|
sub ne { |
1234
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
1235
|
|
|
|
|
|
|
|
1236
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1237
|
0
|
|
|
|
|
0
|
@_ = do { |
1238
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
1239
|
|
|
|
|
|
|
|
1240
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
1241
|
|
|
|
|
|
|
or Hydrogen::croak( |
1242
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1243
|
|
|
|
|
|
|
"ne", scalar(@_), "expected exactly 2 parameters" ); |
1244
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1246
|
0
|
0
|
|
|
|
0
|
do { |
1247
|
|
|
|
|
|
|
|
1248
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1249
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
1250
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
1251
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1252
|
|
|
|
|
|
|
} |
1253
|
|
|
|
|
|
|
} |
1254
|
|
|
|
|
|
|
or Hydrogen::croak( |
1255
|
|
|
|
|
|
|
"Type check failed in signature for ne: %s should be %s", |
1256
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1257
|
|
|
|
|
|
|
|
1258
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
1259
|
0
|
0
|
|
|
|
0
|
do { |
1260
|
|
|
|
|
|
|
|
1261
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1262
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
1263
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
1264
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1265
|
|
|
|
|
|
|
} |
1266
|
|
|
|
|
|
|
} |
1267
|
|
|
|
|
|
|
or Hydrogen::croak( |
1268
|
|
|
|
|
|
|
"Type check failed in signature for ne: %s should be %s", |
1269
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
1270
|
|
|
|
|
|
|
|
1271
|
0
|
|
|
|
|
0
|
(@_); |
1272
|
|
|
|
|
|
|
}; |
1273
|
0
|
|
|
|
|
0
|
$$__REF__ ne $_[1]; |
1274
|
|
|
|
|
|
|
} |
1275
|
|
|
|
|
|
|
|
1276
|
|
|
|
|
|
|
=head2 C<< nei( $string, $str ) >> |
1277
|
|
|
|
|
|
|
|
1278
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
1279
|
|
|
|
|
|
|
|
1280
|
|
|
|
|
|
|
Returns C<< fc($string) ne fc($str) >>. Uses C instead of C in versions of Perl older than 5.16. |
1281
|
|
|
|
|
|
|
|
1282
|
|
|
|
|
|
|
=cut |
1283
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
sub nei { |
1285
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
1286
|
|
|
|
|
|
|
|
1287
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1288
|
0
|
|
|
|
|
0
|
@_ = do { |
1289
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
1290
|
|
|
|
|
|
|
|
1291
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
1292
|
|
|
|
|
|
|
or Hydrogen::croak( |
1293
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1294
|
|
|
|
|
|
|
"nei", scalar(@_), "expected exactly 2 parameters" ); |
1295
|
|
|
|
|
|
|
|
1296
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1297
|
0
|
0
|
|
|
|
0
|
do { |
1298
|
|
|
|
|
|
|
|
1299
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1300
|
0
|
0
|
|
|
|
0
|
defined( $_[0] ) and do { |
1301
|
0
|
0
|
|
|
|
0
|
ref( \$_[0] ) eq 'SCALAR' |
1302
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1303
|
|
|
|
|
|
|
} |
1304
|
|
|
|
|
|
|
} |
1305
|
|
|
|
|
|
|
or Hydrogen::croak( |
1306
|
|
|
|
|
|
|
"Type check failed in signature for nei: %s should be %s", |
1307
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1308
|
|
|
|
|
|
|
|
1309
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
1310
|
0
|
0
|
|
|
|
0
|
do { |
1311
|
|
|
|
|
|
|
|
1312
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1313
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
1314
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
1315
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1316
|
|
|
|
|
|
|
} |
1317
|
|
|
|
|
|
|
} |
1318
|
|
|
|
|
|
|
or Hydrogen::croak( |
1319
|
|
|
|
|
|
|
"Type check failed in signature for nei: %s should be %s", |
1320
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
1321
|
|
|
|
|
|
|
|
1322
|
0
|
|
|
|
|
0
|
(@_); |
1323
|
|
|
|
|
|
|
}; |
1324
|
0
|
|
|
|
|
0
|
Hydrogen::fc($$__REF__) ne Hydrogen::fc( $_[1] ); |
1325
|
|
|
|
|
|
|
} |
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
=head2 C<< prepend( $string, $head ) >> |
1328
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
1330
|
|
|
|
|
|
|
|
1331
|
|
|
|
|
|
|
Prepends another string to the start of the current string and updates the original value. |
1332
|
|
|
|
|
|
|
|
1333
|
|
|
|
|
|
|
=cut |
1334
|
|
|
|
|
|
|
|
1335
|
|
|
|
|
|
|
sub prepend { |
1336
|
1
|
|
|
1
|
1
|
8314
|
my $__REF__ = \$_[0]; |
1337
|
|
|
|
|
|
|
|
1338
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1339
|
1
|
|
|
|
|
3
|
@_ = do { |
1340
|
1
|
|
|
|
|
5
|
my ( %tmp, $tmp ); |
1341
|
|
|
|
|
|
|
|
1342
|
1
|
50
|
|
|
|
8
|
@_ == 2 |
1343
|
|
|
|
|
|
|
or Hydrogen::croak( |
1344
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1345
|
|
|
|
|
|
|
"prepend", scalar(@_), "expected exactly 2 parameters" ); |
1346
|
|
|
|
|
|
|
|
1347
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1348
|
1
|
50
|
|
|
|
2
|
do { |
1349
|
|
|
|
|
|
|
|
1350
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1351
|
1
|
50
|
|
|
|
7
|
defined( $_[0] ) and do { |
1352
|
1
|
50
|
|
|
|
9
|
ref( \$_[0] ) eq 'SCALAR' |
1353
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1354
|
|
|
|
|
|
|
} |
1355
|
|
|
|
|
|
|
} |
1356
|
|
|
|
|
|
|
or Hydrogen::croak( |
1357
|
|
|
|
|
|
|
"Type check failed in signature for prepend: %s should be %s", |
1358
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1359
|
|
|
|
|
|
|
|
1360
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
1361
|
1
|
50
|
|
|
|
3
|
do { |
1362
|
|
|
|
|
|
|
|
1363
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1364
|
1
|
50
|
|
|
|
5
|
defined( $_[1] ) and do { |
1365
|
1
|
50
|
|
|
|
11
|
ref( \$_[1] ) eq 'SCALAR' |
1366
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1367
|
|
|
|
|
|
|
} |
1368
|
|
|
|
|
|
|
} |
1369
|
|
|
|
|
|
|
or Hydrogen::croak( |
1370
|
|
|
|
|
|
|
"Type check failed in signature for prepend: %s should be %s", |
1371
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
1372
|
|
|
|
|
|
|
|
1373
|
1
|
|
|
|
|
4
|
(@_); |
1374
|
|
|
|
|
|
|
}; |
1375
|
|
|
|
|
|
|
( |
1376
|
1
|
|
|
|
|
4
|
${$__REF__} = do { |
|
1
|
|
|
|
|
3
|
|
1377
|
1
|
|
|
|
|
4
|
my $shv_final_unchecked = $_[1] . $$__REF__; |
1378
|
1
|
|
|
|
|
3
|
do { |
1379
|
1
|
50
|
|
|
|
2
|
do { |
1380
|
|
|
|
|
|
|
|
1381
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1382
|
1
|
50
|
|
|
|
3
|
defined($shv_final_unchecked) and do { |
1383
|
1
|
50
|
|
|
|
7
|
ref( \$shv_final_unchecked ) eq 'SCALAR' |
1384
|
|
|
|
|
|
|
or ref( \( my $val = $shv_final_unchecked ) ) eq |
1385
|
|
|
|
|
|
|
'SCALAR'; |
1386
|
|
|
|
|
|
|
} |
1387
|
|
|
|
|
|
|
} |
1388
|
|
|
|
|
|
|
or Hydrogen::croak( |
1389
|
|
|
|
|
|
|
"Type check failed for prepend: expected %s, got value %s", |
1390
|
|
|
|
|
|
|
"Str", $shv_final_unchecked |
1391
|
|
|
|
|
|
|
); |
1392
|
1
|
|
|
|
|
3
|
$shv_final_unchecked; |
1393
|
|
|
|
|
|
|
}; |
1394
|
|
|
|
|
|
|
} |
1395
|
|
|
|
|
|
|
); |
1396
|
|
|
|
|
|
|
} |
1397
|
|
|
|
|
|
|
|
1398
|
|
|
|
|
|
|
=head2 C<< replace( $string, $regexp, $replacement ) >> |
1399
|
|
|
|
|
|
|
|
1400
|
|
|
|
|
|
|
Additional arguments: B<< Str|RegexpRef >>, B<< Str|CodeRef >>. |
1401
|
|
|
|
|
|
|
|
1402
|
|
|
|
|
|
|
Replaces the first regexp match within the string with the replacement string. |
1403
|
|
|
|
|
|
|
|
1404
|
|
|
|
|
|
|
=cut |
1405
|
|
|
|
|
|
|
|
1406
|
|
|
|
|
|
|
sub replace { |
1407
|
2
|
|
|
2
|
1
|
4043
|
my $__REF__ = \$_[0]; |
1408
|
|
|
|
|
|
|
|
1409
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1410
|
2
|
|
|
|
|
5
|
@_ = do { |
1411
|
2
|
|
|
|
|
3
|
my ( %tmp, $tmp ); |
1412
|
|
|
|
|
|
|
|
1413
|
2
|
50
|
|
|
|
7
|
@_ == 3 |
1414
|
|
|
|
|
|
|
or Hydrogen::croak( |
1415
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1416
|
|
|
|
|
|
|
"replace", scalar(@_), "expected exactly 3 parameters" ); |
1417
|
|
|
|
|
|
|
|
1418
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1419
|
2
|
50
|
|
|
|
4
|
do { |
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1422
|
2
|
50
|
|
|
|
8
|
defined( $_[0] ) and do { |
1423
|
2
|
50
|
|
|
|
13
|
ref( \$_[0] ) eq 'SCALAR' |
1424
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1425
|
|
|
|
|
|
|
} |
1426
|
|
|
|
|
|
|
} |
1427
|
|
|
|
|
|
|
or Hydrogen::croak( |
1428
|
|
|
|
|
|
|
"Type check failed in signature for replace: %s should be %s", |
1429
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1430
|
|
|
|
|
|
|
|
1431
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str|RegexpRef) |
1432
|
2
|
50
|
|
|
|
9
|
do { |
1433
|
|
|
|
|
|
|
|
1434
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1435
|
|
|
|
|
|
|
( |
1436
|
|
|
|
|
|
|
do { |
1437
|
|
|
|
|
|
|
|
1438
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1439
|
2
|
50
|
|
|
|
16
|
defined( $_[1] ) and do { |
1440
|
2
|
100
|
|
|
|
25
|
ref( \$_[1] ) eq 'SCALAR' |
1441
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1442
|
|
|
|
|
|
|
} |
1443
|
|
|
|
|
|
|
} |
1444
|
|
|
|
|
|
|
or ( |
1445
|
2
|
100
|
|
|
|
5
|
do { |
1446
|
|
|
|
|
|
|
|
1447
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1448
|
4
|
|
|
4
|
|
31
|
use Scalar::Util (); |
|
4
|
|
|
|
|
46
|
|
|
4
|
|
|
|
|
102
|
|
1449
|
4
|
|
|
4
|
|
28
|
use re (); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1976
|
|
1450
|
1
|
50
|
0
|
|
|
14
|
ref( $_[1] ) && !!re::is_regexp( $_[1] ) |
|
|
|
33
|
|
|
|
|
1451
|
|
|
|
|
|
|
or Scalar::Util::blessed( $_[1] ) |
1452
|
|
|
|
|
|
|
&& $_[1]->isa('Regexp'); |
1453
|
|
|
|
|
|
|
} |
1454
|
|
|
|
|
|
|
) |
1455
|
|
|
|
|
|
|
); |
1456
|
|
|
|
|
|
|
} |
1457
|
|
|
|
|
|
|
or Hydrogen::croak( |
1458
|
|
|
|
|
|
|
"Type check failed in signature for replace: %s should be %s", |
1459
|
|
|
|
|
|
|
"\$_[1]", "Str|RegexpRef" ); |
1460
|
|
|
|
|
|
|
|
1461
|
|
|
|
|
|
|
# Parameter $_[2] (type: Str|CodeRef) |
1462
|
2
|
50
|
|
|
|
4
|
do { |
1463
|
|
|
|
|
|
|
|
1464
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1465
|
|
|
|
|
|
|
( |
1466
|
2
|
100
|
|
|
|
4
|
do { |
1467
|
|
|
|
|
|
|
|
1468
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1469
|
2
|
50
|
|
|
|
9
|
defined( $_[2] ) and do { |
1470
|
2
|
100
|
|
|
|
42
|
ref( \$_[2] ) eq 'SCALAR' |
1471
|
|
|
|
|
|
|
or ref( \( my $val = $_[2] ) ) eq 'SCALAR'; |
1472
|
|
|
|
|
|
|
} |
1473
|
|
|
|
|
|
|
} |
1474
|
|
|
|
|
|
|
or ( ref( $_[2] ) eq 'CODE' ) |
1475
|
|
|
|
|
|
|
); |
1476
|
|
|
|
|
|
|
} |
1477
|
|
|
|
|
|
|
or Hydrogen::croak( |
1478
|
|
|
|
|
|
|
"Type check failed in signature for replace: %s should be %s", |
1479
|
|
|
|
|
|
|
"\$_[2]", "Str|CodeRef" ); |
1480
|
|
|
|
|
|
|
|
1481
|
2
|
|
|
|
|
48
|
(@_); |
1482
|
|
|
|
|
|
|
}; |
1483
|
2
|
|
|
|
|
6
|
my $shv_tmp = $$__REF__; |
1484
|
2
|
100
|
|
|
|
25
|
if ( ( ref( $_[2] ) eq 'CODE' ) ) { |
1485
|
1
|
|
|
|
|
3
|
my $shv_callback = $_[2]; |
1486
|
1
|
|
|
|
|
9
|
$shv_tmp =~ s/$_[1]/$shv_callback->()/e; |
|
1
|
|
|
|
|
4
|
|
1487
|
|
|
|
|
|
|
} |
1488
|
1
|
|
|
|
|
28
|
else { $shv_tmp =~ s/$_[1]/$_[2]/ } |
1489
|
|
|
|
|
|
|
( |
1490
|
2
|
|
|
|
|
8
|
${$__REF__} = do { |
|
2
|
|
|
|
|
6
|
|
1491
|
2
|
|
|
|
|
3
|
my $shv_final_unchecked = $shv_tmp; |
1492
|
2
|
|
|
|
|
4
|
do { |
1493
|
2
|
50
|
|
|
|
5
|
do { |
1494
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1496
|
2
|
50
|
|
|
|
6
|
defined($shv_final_unchecked) and do { |
1497
|
2
|
50
|
|
|
|
15
|
ref( \$shv_final_unchecked ) eq 'SCALAR' |
1498
|
|
|
|
|
|
|
or ref( \( my $val = $shv_final_unchecked ) ) eq |
1499
|
|
|
|
|
|
|
'SCALAR'; |
1500
|
|
|
|
|
|
|
} |
1501
|
|
|
|
|
|
|
} |
1502
|
|
|
|
|
|
|
or Hydrogen::croak( |
1503
|
|
|
|
|
|
|
"Type check failed for replace: expected %s, got value %s", |
1504
|
|
|
|
|
|
|
"Str", $shv_final_unchecked |
1505
|
|
|
|
|
|
|
); |
1506
|
2
|
|
|
|
|
6
|
$shv_final_unchecked; |
1507
|
|
|
|
|
|
|
}; |
1508
|
|
|
|
|
|
|
} |
1509
|
|
|
|
|
|
|
); |
1510
|
|
|
|
|
|
|
} |
1511
|
|
|
|
|
|
|
|
1512
|
|
|
|
|
|
|
=head2 C<< replace_globally( $string, $regexp, $replacement ) >> |
1513
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
Additional arguments: B<< Str|RegexpRef >>, B<< Str|CodeRef >>. |
1515
|
|
|
|
|
|
|
|
1516
|
|
|
|
|
|
|
Replaces the all regexp matches within the string with the replacement string. |
1517
|
|
|
|
|
|
|
|
1518
|
|
|
|
|
|
|
=cut |
1519
|
|
|
|
|
|
|
|
1520
|
|
|
|
|
|
|
sub replace_globally { |
1521
|
2
|
|
|
2
|
1
|
4288
|
my $__REF__ = \$_[0]; |
1522
|
|
|
|
|
|
|
|
1523
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1524
|
2
|
|
|
|
|
5
|
@_ = do { |
1525
|
2
|
|
|
|
|
4
|
my ( %tmp, $tmp ); |
1526
|
|
|
|
|
|
|
|
1527
|
2
|
50
|
|
|
|
15
|
@_ == 3 |
1528
|
|
|
|
|
|
|
or Hydrogen::croak( |
1529
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1530
|
|
|
|
|
|
|
"replace_globally", scalar(@_), "expected exactly 3 parameters" ); |
1531
|
|
|
|
|
|
|
|
1532
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1533
|
2
|
50
|
|
|
|
4
|
do { |
1534
|
|
|
|
|
|
|
|
1535
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1536
|
2
|
50
|
|
|
|
8
|
defined( $_[0] ) and do { |
1537
|
2
|
50
|
|
|
|
15
|
ref( \$_[0] ) eq 'SCALAR' |
1538
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1539
|
|
|
|
|
|
|
} |
1540
|
|
|
|
|
|
|
} |
1541
|
|
|
|
|
|
|
or Hydrogen::croak( |
1542
|
|
|
|
|
|
|
"Type check failed in signature for replace_globally: %s should be %s", |
1543
|
|
|
|
|
|
|
"\$_[0]", "Str" |
1544
|
|
|
|
|
|
|
); |
1545
|
|
|
|
|
|
|
|
1546
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str|RegexpRef) |
1547
|
2
|
50
|
|
|
|
3
|
do { |
1548
|
|
|
|
|
|
|
|
1549
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1550
|
|
|
|
|
|
|
( |
1551
|
|
|
|
|
|
|
do { |
1552
|
|
|
|
|
|
|
|
1553
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1554
|
2
|
50
|
|
|
|
8
|
defined( $_[1] ) and do { |
1555
|
2
|
100
|
|
|
|
21
|
ref( \$_[1] ) eq 'SCALAR' |
1556
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1557
|
|
|
|
|
|
|
} |
1558
|
|
|
|
|
|
|
} |
1559
|
|
|
|
|
|
|
or ( |
1560
|
2
|
100
|
|
|
|
3
|
do { |
1561
|
|
|
|
|
|
|
|
1562
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1563
|
4
|
|
|
4
|
|
29
|
use Scalar::Util (); |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
105
|
|
1564
|
4
|
|
|
4
|
|
34
|
use re (); |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
6877
|
|
1565
|
1
|
50
|
0
|
|
|
9
|
ref( $_[1] ) && !!re::is_regexp( $_[1] ) |
|
|
|
33
|
|
|
|
|
1566
|
|
|
|
|
|
|
or Scalar::Util::blessed( $_[1] ) |
1567
|
|
|
|
|
|
|
&& $_[1]->isa('Regexp'); |
1568
|
|
|
|
|
|
|
} |
1569
|
|
|
|
|
|
|
) |
1570
|
|
|
|
|
|
|
); |
1571
|
|
|
|
|
|
|
} |
1572
|
|
|
|
|
|
|
or Hydrogen::croak( |
1573
|
|
|
|
|
|
|
"Type check failed in signature for replace_globally: %s should be %s", |
1574
|
|
|
|
|
|
|
"\$_[1]", "Str|RegexpRef" |
1575
|
|
|
|
|
|
|
); |
1576
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
# Parameter $_[2] (type: Str|CodeRef) |
1578
|
2
|
50
|
|
|
|
4
|
do { |
1579
|
|
|
|
|
|
|
|
1580
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1581
|
|
|
|
|
|
|
( |
1582
|
2
|
100
|
|
|
|
3
|
do { |
1583
|
|
|
|
|
|
|
|
1584
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1585
|
2
|
50
|
|
|
|
7
|
defined( $_[2] ) and do { |
1586
|
2
|
100
|
|
|
|
19
|
ref( \$_[2] ) eq 'SCALAR' |
1587
|
|
|
|
|
|
|
or ref( \( my $val = $_[2] ) ) eq 'SCALAR'; |
1588
|
|
|
|
|
|
|
} |
1589
|
|
|
|
|
|
|
} |
1590
|
|
|
|
|
|
|
or ( ref( $_[2] ) eq 'CODE' ) |
1591
|
|
|
|
|
|
|
); |
1592
|
|
|
|
|
|
|
} |
1593
|
|
|
|
|
|
|
or Hydrogen::croak( |
1594
|
|
|
|
|
|
|
"Type check failed in signature for replace_globally: %s should be %s", |
1595
|
|
|
|
|
|
|
"\$_[2]", "Str|CodeRef" |
1596
|
|
|
|
|
|
|
); |
1597
|
|
|
|
|
|
|
|
1598
|
2
|
|
|
|
|
8
|
(@_); |
1599
|
|
|
|
|
|
|
}; |
1600
|
2
|
|
|
|
|
6
|
my $shv_tmp = $$__REF__; |
1601
|
2
|
100
|
|
|
|
6
|
if ( ( ref( $_[2] ) eq 'CODE' ) ) { |
1602
|
1
|
|
|
|
|
4
|
my $shv_callback = $_[2]; |
1603
|
1
|
|
|
|
|
7
|
$shv_tmp =~ s/$_[1]/$shv_callback->()/eg; |
|
2
|
|
|
|
|
9
|
|
1604
|
|
|
|
|
|
|
} |
1605
|
1
|
|
|
|
|
16
|
else { $shv_tmp =~ s/$_[1]/$_[2]/g } |
1606
|
|
|
|
|
|
|
( |
1607
|
2
|
|
|
|
|
7
|
${$__REF__} = do { |
|
2
|
|
|
|
|
6
|
|
1608
|
2
|
|
|
|
|
3
|
my $shv_final_unchecked = $shv_tmp; |
1609
|
2
|
|
|
|
|
16
|
do { |
1610
|
2
|
50
|
|
|
|
3
|
do { |
1611
|
|
|
|
|
|
|
|
1612
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1613
|
2
|
50
|
|
|
|
8
|
defined($shv_final_unchecked) and do { |
1614
|
2
|
50
|
|
|
|
13
|
ref( \$shv_final_unchecked ) eq 'SCALAR' |
1615
|
|
|
|
|
|
|
or ref( \( my $val = $shv_final_unchecked ) ) eq |
1616
|
|
|
|
|
|
|
'SCALAR'; |
1617
|
|
|
|
|
|
|
} |
1618
|
|
|
|
|
|
|
} |
1619
|
|
|
|
|
|
|
or Hydrogen::croak( |
1620
|
|
|
|
|
|
|
"Type check failed for replace_globally: expected %s, got value %s", |
1621
|
|
|
|
|
|
|
"Str", $shv_final_unchecked |
1622
|
|
|
|
|
|
|
); |
1623
|
2
|
|
|
|
|
4
|
$shv_final_unchecked; |
1624
|
|
|
|
|
|
|
}; |
1625
|
|
|
|
|
|
|
} |
1626
|
|
|
|
|
|
|
); |
1627
|
|
|
|
|
|
|
} |
1628
|
|
|
|
|
|
|
|
1629
|
|
|
|
|
|
|
=head2 C<< reset( $string ) >> |
1630
|
|
|
|
|
|
|
|
1631
|
|
|
|
|
|
|
Resets the original value to its default value, or an empty string if it has no default. |
1632
|
|
|
|
|
|
|
|
1633
|
|
|
|
|
|
|
=cut |
1634
|
|
|
|
|
|
|
|
1635
|
|
|
|
|
|
|
sub reset { |
1636
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
1637
|
|
|
|
|
|
|
|
1638
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1639
|
0
|
0
|
|
|
|
0
|
@_ == 1 |
1640
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for reset; usage: " |
1641
|
|
|
|
|
|
|
. "Hydrogen::String::reset( \$string )" ); |
1642
|
|
|
|
|
|
|
( |
1643
|
0
|
|
|
|
|
0
|
${$__REF__} = do { |
|
0
|
|
|
|
|
0
|
|
1644
|
0
|
|
|
|
|
0
|
my $shv_final_unchecked = q{}; |
1645
|
0
|
|
|
|
|
0
|
do { |
1646
|
0
|
0
|
|
|
|
0
|
do { |
1647
|
|
|
|
|
|
|
|
1648
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1649
|
0
|
0
|
|
|
|
0
|
defined($shv_final_unchecked) and do { |
1650
|
0
|
0
|
|
|
|
0
|
ref( \$shv_final_unchecked ) eq 'SCALAR' |
1651
|
|
|
|
|
|
|
or ref( \( my $val = $shv_final_unchecked ) ) eq |
1652
|
|
|
|
|
|
|
'SCALAR'; |
1653
|
|
|
|
|
|
|
} |
1654
|
|
|
|
|
|
|
} |
1655
|
|
|
|
|
|
|
or Hydrogen::croak( |
1656
|
|
|
|
|
|
|
"Type check failed for reset: expected %s, got value %s", |
1657
|
|
|
|
|
|
|
"Str", $shv_final_unchecked ); |
1658
|
0
|
|
|
|
|
0
|
$shv_final_unchecked; |
1659
|
|
|
|
|
|
|
}; |
1660
|
|
|
|
|
|
|
} |
1661
|
|
|
|
|
|
|
); |
1662
|
|
|
|
|
|
|
} |
1663
|
|
|
|
|
|
|
|
1664
|
|
|
|
|
|
|
=head2 C<< set( $string, $value ) >> |
1665
|
|
|
|
|
|
|
|
1666
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
1667
|
|
|
|
|
|
|
|
1668
|
|
|
|
|
|
|
Sets the string to a new value. |
1669
|
|
|
|
|
|
|
|
1670
|
|
|
|
|
|
|
=cut |
1671
|
|
|
|
|
|
|
|
1672
|
|
|
|
|
|
|
sub set { |
1673
|
1
|
|
|
1
|
1
|
6135
|
my $__REF__ = \$_[0]; |
1674
|
|
|
|
|
|
|
|
1675
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1676
|
1
|
|
|
|
|
2
|
@_ = do { |
1677
|
1
|
|
|
|
|
3
|
my ( %tmp, $tmp ); |
1678
|
|
|
|
|
|
|
|
1679
|
1
|
50
|
|
|
|
4
|
@_ == 2 |
1680
|
|
|
|
|
|
|
or Hydrogen::croak( |
1681
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1682
|
|
|
|
|
|
|
"set", scalar(@_), "expected exactly 2 parameters" ); |
1683
|
|
|
|
|
|
|
|
1684
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1685
|
1
|
50
|
|
|
|
2
|
do { |
1686
|
|
|
|
|
|
|
|
1687
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1688
|
1
|
50
|
|
|
|
5
|
defined( $_[0] ) and do { |
1689
|
1
|
50
|
|
|
|
9
|
ref( \$_[0] ) eq 'SCALAR' |
1690
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1691
|
|
|
|
|
|
|
} |
1692
|
|
|
|
|
|
|
} |
1693
|
|
|
|
|
|
|
or Hydrogen::croak( |
1694
|
|
|
|
|
|
|
"Type check failed in signature for set: %s should be %s", |
1695
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1696
|
|
|
|
|
|
|
|
1697
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
1698
|
1
|
50
|
|
|
|
3
|
do { |
1699
|
|
|
|
|
|
|
|
1700
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1701
|
1
|
50
|
|
|
|
4
|
defined( $_[1] ) and do { |
1702
|
1
|
50
|
|
|
|
7
|
ref( \$_[1] ) eq 'SCALAR' |
1703
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1704
|
|
|
|
|
|
|
} |
1705
|
|
|
|
|
|
|
} |
1706
|
|
|
|
|
|
|
or Hydrogen::croak( |
1707
|
|
|
|
|
|
|
"Type check failed in signature for set: %s should be %s", |
1708
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
1709
|
|
|
|
|
|
|
|
1710
|
1
|
|
|
|
|
4
|
(@_); |
1711
|
|
|
|
|
|
|
}; |
1712
|
|
|
|
|
|
|
( |
1713
|
1
|
|
|
|
|
2
|
${$__REF__} = do { |
|
1
|
|
|
|
|
3
|
|
1714
|
1
|
|
|
|
|
2
|
my $shv_final_unchecked = $_[1]; |
1715
|
1
|
|
|
|
|
2
|
do { |
1716
|
1
|
50
|
|
|
|
2
|
do { |
1717
|
|
|
|
|
|
|
|
1718
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1719
|
1
|
50
|
|
|
|
7
|
defined($shv_final_unchecked) and do { |
1720
|
1
|
50
|
|
|
|
8
|
ref( \$shv_final_unchecked ) eq 'SCALAR' |
1721
|
|
|
|
|
|
|
or ref( \( my $val = $shv_final_unchecked ) ) eq |
1722
|
|
|
|
|
|
|
'SCALAR'; |
1723
|
|
|
|
|
|
|
} |
1724
|
|
|
|
|
|
|
} |
1725
|
|
|
|
|
|
|
or Hydrogen::croak( |
1726
|
|
|
|
|
|
|
"Type check failed for set: expected %s, got value %s", |
1727
|
|
|
|
|
|
|
"Str", $shv_final_unchecked ); |
1728
|
1
|
|
|
|
|
3
|
$shv_final_unchecked; |
1729
|
|
|
|
|
|
|
}; |
1730
|
|
|
|
|
|
|
} |
1731
|
|
|
|
|
|
|
); |
1732
|
|
|
|
|
|
|
} |
1733
|
|
|
|
|
|
|
|
1734
|
|
|
|
|
|
|
=head2 C<< starts_with( $string, $head ) >> |
1735
|
|
|
|
|
|
|
|
1736
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
1737
|
|
|
|
|
|
|
|
1738
|
|
|
|
|
|
|
Returns true iff the string starts with C<< $head >>. |
1739
|
|
|
|
|
|
|
|
1740
|
|
|
|
|
|
|
=cut |
1741
|
|
|
|
|
|
|
|
1742
|
|
|
|
|
|
|
sub starts_with { |
1743
|
0
|
|
|
0
|
1
|
|
my $__REF__ = \$_[0]; |
1744
|
|
|
|
|
|
|
|
1745
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1746
|
0
|
|
|
|
|
|
@_ = do { |
1747
|
0
|
|
|
|
|
|
my ( %tmp, $tmp ); |
1748
|
|
|
|
|
|
|
|
1749
|
0
|
0
|
|
|
|
|
@_ == 2 |
1750
|
|
|
|
|
|
|
or Hydrogen::croak( |
1751
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1752
|
|
|
|
|
|
|
"starts_with", scalar(@_), "expected exactly 2 parameters" ); |
1753
|
|
|
|
|
|
|
|
1754
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1755
|
0
|
0
|
|
|
|
|
do { |
1756
|
|
|
|
|
|
|
|
1757
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1758
|
0
|
0
|
|
|
|
|
defined( $_[0] ) and do { |
1759
|
0
|
0
|
|
|
|
|
ref( \$_[0] ) eq 'SCALAR' |
1760
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1761
|
|
|
|
|
|
|
} |
1762
|
|
|
|
|
|
|
} |
1763
|
|
|
|
|
|
|
or Hydrogen::croak( |
1764
|
|
|
|
|
|
|
"Type check failed in signature for starts_with: %s should be %s", |
1765
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1766
|
|
|
|
|
|
|
|
1767
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
1768
|
0
|
0
|
|
|
|
|
do { |
1769
|
|
|
|
|
|
|
|
1770
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1771
|
0
|
0
|
|
|
|
|
defined( $_[1] ) and do { |
1772
|
0
|
0
|
|
|
|
|
ref( \$_[1] ) eq 'SCALAR' |
1773
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1774
|
|
|
|
|
|
|
} |
1775
|
|
|
|
|
|
|
} |
1776
|
|
|
|
|
|
|
or Hydrogen::croak( |
1777
|
|
|
|
|
|
|
"Type check failed in signature for starts_with: %s should be %s", |
1778
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
1779
|
|
|
|
|
|
|
|
1780
|
0
|
|
|
|
|
|
(@_); |
1781
|
|
|
|
|
|
|
}; |
1782
|
0
|
|
|
|
|
|
substr( $$__REF__, 0, length $_[1] ) eq $_[1]; |
1783
|
|
|
|
|
|
|
} |
1784
|
|
|
|
|
|
|
|
1785
|
|
|
|
|
|
|
=head2 C<< starts_with_i( $string, $head ) >> |
1786
|
|
|
|
|
|
|
|
1787
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
1788
|
|
|
|
|
|
|
|
1789
|
|
|
|
|
|
|
Returns true iff the string starts with C<< $head >> case-insensitvely. |
1790
|
|
|
|
|
|
|
|
1791
|
|
|
|
|
|
|
=cut |
1792
|
|
|
|
|
|
|
|
1793
|
|
|
|
|
|
|
sub starts_with_i { |
1794
|
0
|
|
|
0
|
1
|
|
my $__REF__ = \$_[0]; |
1795
|
|
|
|
|
|
|
|
1796
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1797
|
0
|
|
|
|
|
|
@_ = do { |
1798
|
0
|
|
|
|
|
|
my ( %tmp, $tmp ); |
1799
|
|
|
|
|
|
|
|
1800
|
0
|
0
|
|
|
|
|
@_ == 2 |
1801
|
|
|
|
|
|
|
or Hydrogen::croak( |
1802
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1803
|
|
|
|
|
|
|
"starts_with_i", scalar(@_), "expected exactly 2 parameters" ); |
1804
|
|
|
|
|
|
|
|
1805
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1806
|
0
|
0
|
|
|
|
|
do { |
1807
|
|
|
|
|
|
|
|
1808
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1809
|
0
|
0
|
|
|
|
|
defined( $_[0] ) and do { |
1810
|
0
|
0
|
|
|
|
|
ref( \$_[0] ) eq 'SCALAR' |
1811
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1812
|
|
|
|
|
|
|
} |
1813
|
|
|
|
|
|
|
} |
1814
|
|
|
|
|
|
|
or Hydrogen::croak( |
1815
|
|
|
|
|
|
|
"Type check failed in signature for starts_with_i: %s should be %s", |
1816
|
|
|
|
|
|
|
"\$_[0]", "Str" |
1817
|
|
|
|
|
|
|
); |
1818
|
|
|
|
|
|
|
|
1819
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
1820
|
0
|
0
|
|
|
|
|
do { |
1821
|
|
|
|
|
|
|
|
1822
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1823
|
0
|
0
|
|
|
|
|
defined( $_[1] ) and do { |
1824
|
0
|
0
|
|
|
|
|
ref( \$_[1] ) eq 'SCALAR' |
1825
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
1826
|
|
|
|
|
|
|
} |
1827
|
|
|
|
|
|
|
} |
1828
|
|
|
|
|
|
|
or Hydrogen::croak( |
1829
|
|
|
|
|
|
|
"Type check failed in signature for starts_with_i: %s should be %s", |
1830
|
|
|
|
|
|
|
"\$_[1]", "Str" |
1831
|
|
|
|
|
|
|
); |
1832
|
|
|
|
|
|
|
|
1833
|
0
|
|
|
|
|
|
(@_); |
1834
|
|
|
|
|
|
|
}; |
1835
|
0
|
|
|
|
|
|
Hydrogen::fc( substr( $$__REF__, 0, length $_[1] ) ) eq Hydrogen::fc( $_[1] ); |
1836
|
|
|
|
|
|
|
} |
1837
|
|
|
|
|
|
|
|
1838
|
|
|
|
|
|
|
=head2 C<< substr( $string, $start, $length?, $replacement? ) >> |
1839
|
|
|
|
|
|
|
|
1840
|
|
|
|
|
|
|
Additional arguments: B<< Int >>, B<< Optional[Int] >>, B<< Optional[Str] >>. |
1841
|
|
|
|
|
|
|
|
1842
|
|
|
|
|
|
|
Like C from L, but is not an lvalue. |
1843
|
|
|
|
|
|
|
|
1844
|
|
|
|
|
|
|
=cut |
1845
|
|
|
|
|
|
|
|
1846
|
|
|
|
|
|
|
{ |
1847
|
|
|
|
|
|
|
my $__signature; |
1848
|
|
|
|
|
|
|
|
1849
|
|
|
|
|
|
|
sub substr { |
1850
|
0
|
|
|
0
|
1
|
|
my $__REF__ = \$_[0]; |
1851
|
|
|
|
|
|
|
|
1852
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1853
|
|
|
|
|
|
|
$__signature ||= sub { |
1854
|
0
|
|
|
0
|
|
|
my ( %tmp, $tmp ); |
1855
|
|
|
|
|
|
|
|
1856
|
0
|
0
|
0
|
|
|
|
@_ >= 2 && @_ <= 4 |
1857
|
|
|
|
|
|
|
or Hydrogen::croak( |
1858
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
1859
|
|
|
|
|
|
|
"substr", scalar(@_), "expected exactly 2 parameters" ); |
1860
|
|
|
|
|
|
|
|
1861
|
|
|
|
|
|
|
# Parameter $_[0] (type: Str) |
1862
|
0
|
0
|
|
|
|
|
do { |
1863
|
|
|
|
|
|
|
|
1864
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1865
|
0
|
0
|
|
|
|
|
defined( $_[0] ) and do { |
1866
|
0
|
0
|
|
|
|
|
ref( \$_[0] ) eq 'SCALAR' |
1867
|
|
|
|
|
|
|
or ref( \( my $val = $_[0] ) ) eq 'SCALAR'; |
1868
|
|
|
|
|
|
|
} |
1869
|
|
|
|
|
|
|
} |
1870
|
|
|
|
|
|
|
or Hydrogen::croak( |
1871
|
|
|
|
|
|
|
"Type check failed in signature for substr: %s should be %s", |
1872
|
|
|
|
|
|
|
"\$_[0]", "Str" ); |
1873
|
|
|
|
|
|
|
|
1874
|
|
|
|
|
|
|
# Parameter $_[1] (type: Int) |
1875
|
|
|
|
|
|
|
( |
1876
|
0
|
0
|
|
|
|
|
do { |
1877
|
0
|
|
|
|
|
|
my $tmp = $_[1]; |
1878
|
0
|
0
|
0
|
|
|
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
1879
|
|
|
|
|
|
|
} |
1880
|
|
|
|
|
|
|
) |
1881
|
|
|
|
|
|
|
or Hydrogen::croak( |
1882
|
|
|
|
|
|
|
"Type check failed in signature for substr: %s should be %s", |
1883
|
|
|
|
|
|
|
"\$_[1]", "Int" ); |
1884
|
|
|
|
|
|
|
|
1885
|
|
|
|
|
|
|
# Parameter $_[2] (type: Optional[Int]) |
1886
|
0
|
0
|
|
|
|
|
$#_ >= 2 |
1887
|
|
|
|
|
|
|
or return (@_); |
1888
|
|
|
|
|
|
|
( |
1889
|
0
|
0
|
|
|
|
|
do { |
1890
|
0
|
|
|
|
|
|
my $tmp = $_[2]; |
1891
|
0
|
0
|
0
|
|
|
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
1892
|
|
|
|
|
|
|
} |
1893
|
|
|
|
|
|
|
) |
1894
|
|
|
|
|
|
|
or Hydrogen::croak( |
1895
|
|
|
|
|
|
|
"Type check failed in signature for substr: %s should be %s", |
1896
|
|
|
|
|
|
|
"\$_[2]", "Optional[Int]" ); |
1897
|
|
|
|
|
|
|
|
1898
|
|
|
|
|
|
|
# Parameter $_[3] (type: Optional[Str]) |
1899
|
0
|
0
|
|
|
|
|
$#_ >= 3 |
1900
|
|
|
|
|
|
|
or return (@_); |
1901
|
0
|
0
|
|
|
|
|
do { |
1902
|
|
|
|
|
|
|
|
1903
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1904
|
0
|
0
|
|
|
|
|
defined( $_[3] ) and do { |
1905
|
0
|
0
|
|
|
|
|
ref( \$_[3] ) eq 'SCALAR' |
1906
|
|
|
|
|
|
|
or ref( \( my $val = $_[3] ) ) eq 'SCALAR'; |
1907
|
|
|
|
|
|
|
} |
1908
|
|
|
|
|
|
|
} |
1909
|
|
|
|
|
|
|
or Hydrogen::croak( |
1910
|
|
|
|
|
|
|
"Type check failed in signature for substr: %s should be %s", |
1911
|
|
|
|
|
|
|
"\$_[3]", "Optional[Str]" ); |
1912
|
|
|
|
|
|
|
|
1913
|
0
|
|
|
|
|
|
(@_); |
1914
|
0
|
|
0
|
|
|
|
}; |
1915
|
0
|
|
|
|
|
|
@_ = &$__signature; |
1916
|
0
|
0
|
|
|
|
|
if ( ( @_ - 1 ) == 1 ) { substr( $$__REF__, $_[1] ) } |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1917
|
0
|
|
|
|
|
|
elsif ( ( @_ - 1 ) == 2 ) { substr( $$__REF__, $_[1], $_[2] ) } |
1918
|
|
|
|
|
|
|
elsif ( ( @_ - 1 ) == 3 ) { |
1919
|
0
|
|
|
|
|
|
my $shv_tmp = $$__REF__; |
1920
|
0
|
|
|
|
|
|
my $shv_return = substr( $shv_tmp, $_[1], $_[2], $_[3] ); |
1921
|
|
|
|
|
|
|
( |
1922
|
0
|
|
|
|
|
|
${$__REF__} = do { |
|
0
|
|
|
|
|
|
|
1923
|
0
|
|
|
|
|
|
my $shv_final_unchecked = $shv_tmp; |
1924
|
0
|
|
|
|
|
|
do { |
1925
|
0
|
0
|
|
|
|
|
do { |
1926
|
|
|
|
|
|
|
|
1927
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1928
|
0
|
0
|
|
|
|
|
defined($shv_final_unchecked) and do { |
1929
|
0
|
0
|
|
|
|
|
ref( \$shv_final_unchecked ) eq 'SCALAR' |
1930
|
|
|
|
|
|
|
or ref( \( my $val = $shv_final_unchecked ) ) |
1931
|
|
|
|
|
|
|
eq 'SCALAR'; |
1932
|
|
|
|
|
|
|
} |
1933
|
|
|
|
|
|
|
} |
1934
|
|
|
|
|
|
|
or Hydrogen::croak( |
1935
|
|
|
|
|
|
|
"Type check failed for substr: expected %s, got value %s", |
1936
|
|
|
|
|
|
|
"Str", $shv_final_unchecked |
1937
|
|
|
|
|
|
|
); |
1938
|
0
|
|
|
|
|
|
$shv_final_unchecked; |
1939
|
|
|
|
|
|
|
}; |
1940
|
|
|
|
|
|
|
} |
1941
|
|
|
|
|
|
|
); |
1942
|
0
|
|
|
|
|
|
$shv_return; |
1943
|
|
|
|
|
|
|
} |
1944
|
|
|
|
|
|
|
} |
1945
|
|
|
|
|
|
|
} |
1946
|
|
|
|
|
|
|
|
1947
|
|
|
|
|
|
|
=head2 C<< uc( $string ) >> |
1948
|
|
|
|
|
|
|
|
1949
|
|
|
|
|
|
|
Returns C<< uc($string) >>. |
1950
|
|
|
|
|
|
|
|
1951
|
|
|
|
|
|
|
=cut |
1952
|
|
|
|
|
|
|
|
1953
|
|
|
|
|
|
|
sub uc { |
1954
|
0
|
|
|
0
|
1
|
|
my $__REF__ = \$_[0]; |
1955
|
|
|
|
|
|
|
|
1956
|
|
|
|
|
|
|
package Hydrogen::String::__SANDBOX__; |
1957
|
0
|
0
|
|
|
|
|
@_ == 1 |
1958
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for uc; usage: " |
1959
|
|
|
|
|
|
|
. "Hydrogen::String::uc( \$string )" ); |
1960
|
0
|
|
|
|
|
|
uc($$__REF__); |
1961
|
|
|
|
|
|
|
} |
1962
|
|
|
|
|
|
|
|
1963
|
|
|
|
|
|
|
1; |
1964
|
|
|
|
|
|
|
|
1965
|
|
|
|
|
|
|
=head1 EXPORT |
1966
|
|
|
|
|
|
|
|
1967
|
|
|
|
|
|
|
No functions are exported by this module by default. To import them all (this is usually a bad idea), use: |
1968
|
|
|
|
|
|
|
|
1969
|
|
|
|
|
|
|
use Hydrogen::String -all; |
1970
|
|
|
|
|
|
|
|
1971
|
|
|
|
|
|
|
To import a particular function, use: |
1972
|
|
|
|
|
|
|
|
1973
|
|
|
|
|
|
|
use Hydrogen::String 'chop'; |
1974
|
|
|
|
|
|
|
|
1975
|
|
|
|
|
|
|
To rename functions: |
1976
|
|
|
|
|
|
|
|
1977
|
|
|
|
|
|
|
use Hydrogen::String 'chop' => { -as => 'myfunc' }; |
1978
|
|
|
|
|
|
|
|
1979
|
|
|
|
|
|
|
On Perl 5.37.2+, you can import lexically: |
1980
|
|
|
|
|
|
|
|
1981
|
|
|
|
|
|
|
use Hydrogen::String -lexical, 'chop'; |
1982
|
|
|
|
|
|
|
|
1983
|
|
|
|
|
|
|
See L for more hints on importing. |
1984
|
|
|
|
|
|
|
|
1985
|
|
|
|
|
|
|
=head1 BUGS |
1986
|
|
|
|
|
|
|
|
1987
|
|
|
|
|
|
|
Please report any bugs to |
1988
|
|
|
|
|
|
|
L. |
1989
|
|
|
|
|
|
|
|
1990
|
|
|
|
|
|
|
=head1 SEE ALSO |
1991
|
|
|
|
|
|
|
|
1992
|
|
|
|
|
|
|
L, |
1993
|
|
|
|
|
|
|
L, |
1994
|
|
|
|
|
|
|
L, |
1995
|
|
|
|
|
|
|
L. |
1996
|
|
|
|
|
|
|
|
1997
|
|
|
|
|
|
|
=head1 AUTHOR |
1998
|
|
|
|
|
|
|
|
1999
|
|
|
|
|
|
|
Toby Inkster Etobyink@cpan.orgE. |
2000
|
|
|
|
|
|
|
|
2001
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
2002
|
|
|
|
|
|
|
|
2003
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Toby Inkster. |
2004
|
|
|
|
|
|
|
|
2005
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
2006
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
2007
|
|
|
|
|
|
|
|
2008
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
2009
|
|
|
|
|
|
|
|
2010
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
2011
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
2012
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
2013
|
|
|
|
|
|
|
|