line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Enum; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
18
|
use 5.018; |
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Venus::Class 'base'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
base 'Venus::Sealed'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use overload ( |
13
|
8
|
|
100
|
8
|
|
538
|
'""' => sub{$_[0]->value // ''}, |
14
|
0
|
|
0
|
0
|
|
0
|
'~~' => sub{$_[0]->value // ''}, |
15
|
2
|
|
50
|
2
|
|
16
|
'eq' => sub{($_[0]->value // '') eq "$_[1]"}, |
16
|
2
|
|
100
|
2
|
|
32
|
'ne' => sub{($_[0]->value // '') ne "$_[1]"}, |
17
|
1
|
|
|
1
|
|
3
|
'qr' => sub{qr/@{[quotemeta($_[0])]}/}, |
|
1
|
|
|
|
|
4
|
|
18
|
1
|
|
|
|
|
12
|
fallback => 1, |
19
|
1
|
|
|
1
|
|
8
|
); |
|
1
|
|
|
|
|
1
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# BUILDERS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub build_arg { |
24
|
26
|
|
|
26
|
0
|
52
|
my ($self, $data) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
return { |
27
|
26
|
|
|
|
|
98
|
value => $data, |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub build_args { |
32
|
35
|
|
|
35
|
0
|
70
|
my ($self, $data) = @_; |
33
|
|
|
|
|
|
|
|
34
|
35
|
50
|
33
|
|
|
180
|
if (not(keys %$data == 1 && exists $data->{value})) { |
35
|
0
|
|
|
|
|
0
|
$data = {value => $data}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
35
|
|
|
|
|
114
|
my $value = $data->{value}; |
39
|
|
|
|
|
|
|
|
40
|
35
|
50
|
|
|
|
78
|
if (!ref $value) { |
41
|
0
|
|
|
|
|
0
|
$value = {} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
35
|
100
|
|
|
|
79
|
if (ref $value eq 'ARRAY') { |
45
|
26
|
|
|
|
|
46
|
$value = {map +(s/\W//gr, $_), @{$value}}; |
|
26
|
|
|
|
|
220
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else { |
48
|
9
|
|
|
|
|
17
|
$value = {map +(s/\W//gr, $value->{$_}), keys %{$value}}; |
|
9
|
|
|
|
|
92
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$data->{value} = { |
52
|
|
|
|
|
|
|
names => $value, |
53
|
35
|
|
|
|
|
74
|
codes => {reverse %{$value}}, |
|
35
|
|
|
|
|
184
|
|
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
35
|
|
|
|
|
144
|
return $self->SUPER::build_args($data); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# METHODS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub __get { |
62
|
9
|
|
|
9
|
|
30
|
my ($self, $init, $data, $name) = @_; |
63
|
|
|
|
|
|
|
|
64
|
9
|
50
|
|
|
|
31
|
return undef if !$name; |
65
|
|
|
|
|
|
|
|
66
|
9
|
|
33
|
|
|
26
|
my $class = ref $self || $self; |
67
|
|
|
|
|
|
|
|
68
|
9
|
|
|
|
|
49
|
my $enum = $class->new(value => $init->{value}->{names}); |
69
|
|
|
|
|
|
|
|
70
|
9
|
|
|
|
|
44
|
$enum->{set} = 1; |
71
|
|
|
|
|
|
|
|
72
|
9
|
|
|
|
|
53
|
$enum->set($name); |
73
|
|
|
|
|
|
|
|
74
|
9
|
|
|
|
|
17
|
delete $enum->{set}; |
75
|
|
|
|
|
|
|
|
76
|
9
|
|
|
|
|
163
|
return $enum; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub __set { |
80
|
9
|
|
|
9
|
|
59
|
my ($self, $init, $data, $name) = @_; |
81
|
|
|
|
|
|
|
|
82
|
9
|
50
|
|
|
|
20
|
return undef if !$name; |
83
|
|
|
|
|
|
|
|
84
|
9
|
50
|
|
|
|
23
|
return $self if !exists $self->{set}; |
85
|
|
|
|
|
|
|
|
86
|
9
|
|
|
|
|
19
|
my $names = $init->{value}->{names}; |
87
|
|
|
|
|
|
|
|
88
|
9
|
50
|
|
|
|
19
|
return $self if !exists $names->{$name}; |
89
|
|
|
|
|
|
|
|
90
|
9
|
|
33
|
|
|
45
|
$data->{named} //= $name; |
91
|
|
|
|
|
|
|
|
92
|
9
|
|
|
|
|
39
|
return $self; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub __has { |
96
|
2
|
|
|
2
|
|
7
|
my ($self, $init, $data, $match) = @_; |
97
|
|
|
|
|
|
|
|
98
|
2
|
50
|
|
|
|
5
|
return false if !$match; |
99
|
|
|
|
|
|
|
|
100
|
2
|
|
|
|
|
4
|
my $names = $init->{value}->{names}; |
101
|
|
|
|
|
|
|
|
102
|
2
|
100
|
|
|
|
40
|
return true if $names->{$match}; |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
3
|
my $codes = $init->{value}->{codes}; |
105
|
|
|
|
|
|
|
|
106
|
1
|
50
|
|
|
|
3
|
return true if $codes->{$match}; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
5
|
return false; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub __is { |
112
|
2
|
|
|
2
|
|
5
|
my ($self, $init, $data, $match) = @_; |
113
|
|
|
|
|
|
|
|
114
|
2
|
50
|
|
|
|
8
|
return false if !$match; |
115
|
|
|
|
|
|
|
|
116
|
2
|
|
|
|
|
17
|
my $name = $self->name; |
117
|
|
|
|
|
|
|
|
118
|
2
|
100
|
|
|
|
8
|
return true if $name eq $match; |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
5
|
my $value = $self->value; |
121
|
|
|
|
|
|
|
|
122
|
1
|
50
|
|
|
|
4
|
return true if $value eq $match; |
123
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
9
|
return false; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub __name { |
128
|
4
|
|
|
4
|
|
10
|
my ($self, $init, $data) = @_; |
129
|
|
|
|
|
|
|
|
130
|
4
|
|
|
|
|
23
|
return $data->{named}; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub __names { |
134
|
2
|
|
|
2
|
|
14
|
my ($self, $init, $data) = @_; |
135
|
|
|
|
|
|
|
|
136
|
2
|
|
|
|
|
6
|
my $names = $init->{value}->{names}; |
137
|
|
|
|
|
|
|
|
138
|
2
|
|
|
|
|
3
|
my $list = [sort keys %{$names}]; |
|
2
|
|
|
|
|
13
|
|
139
|
|
|
|
|
|
|
|
140
|
2
|
100
|
|
|
|
14
|
return wantarray ? (@{$list}) : $list; |
|
1
|
|
|
|
|
12
|
|
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub __items { |
144
|
2
|
|
|
2
|
|
5
|
my ($self, $init, $data) = @_; |
145
|
|
|
|
|
|
|
|
146
|
2
|
|
|
|
|
8
|
my $names = $init->{value}->{names}; |
147
|
|
|
|
|
|
|
|
148
|
2
|
|
|
|
|
14
|
my $list = [map [$_, $names->{$_}], $self->list]; |
149
|
|
|
|
|
|
|
|
150
|
2
|
100
|
|
|
|
12
|
return wantarray ? (@{$list}) : $list; |
|
1
|
|
|
|
|
9
|
|
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub __list { |
154
|
4
|
|
|
4
|
|
10
|
my ($self, $init, $data) = @_; |
155
|
|
|
|
|
|
|
|
156
|
4
|
|
|
|
|
11
|
my $codes = $init->{value}->{codes}; |
157
|
|
|
|
|
|
|
|
158
|
4
|
|
|
|
|
7
|
my $list = [map $codes->{$_}, sort keys %{$codes}]; |
|
4
|
|
|
|
|
47
|
|
159
|
|
|
|
|
|
|
|
160
|
4
|
100
|
|
|
|
21
|
return wantarray ? (@{$list}) : $list; |
|
3
|
|
|
|
|
32
|
|
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub __value { |
164
|
17
|
|
|
17
|
|
54
|
my ($self, $init, $data) = @_; |
165
|
|
|
|
|
|
|
|
166
|
17
|
|
|
|
|
32
|
my $value = $data->{named}; |
167
|
|
|
|
|
|
|
|
168
|
17
|
100
|
|
|
|
127
|
return undef if !defined $value; |
169
|
|
|
|
|
|
|
|
170
|
11
|
|
|
|
|
124
|
return $init->{value}->{names}->{$value}; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub __values { |
174
|
2
|
|
|
2
|
|
7
|
my ($self, $init, $data) = @_; |
175
|
|
|
|
|
|
|
|
176
|
2
|
|
|
|
|
4
|
my $codes = $init->{value}->{codes}; |
177
|
|
|
|
|
|
|
|
178
|
2
|
|
|
|
|
7
|
my $list = [sort keys %{$codes}]; |
|
2
|
|
|
|
|
11
|
|
179
|
|
|
|
|
|
|
|
180
|
2
|
100
|
|
|
|
17
|
return wantarray ? (@{$list}) : $list; |
|
1
|
|
|
|
|
10
|
|
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
1; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 NAME |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Venus::Enum - Enum Class |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 ABSTRACT |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Enum Class for Perl 5 |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=cut |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 SYNOPSIS |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
package main; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
use Venus::Enum; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
my $enum = Venus::Enum->new(['n', 's', 'e', 'w']); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# my $north = $enum->get('n'); |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# "n" |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 DESCRIPTION |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
This package provides an interface for working with enumerations. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 INHERITS |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
This package inherits behaviors from: |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
L |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 METHODS |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
This package provides the following methods: |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head2 get |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
get(string $name) (Venus::Enum) |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
The get method returns a new object representing the enum member specified. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
I> |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=over 4 |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item get example 1 |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# given: synopsis |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
package main; |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
my $get = $enum->get('n'); |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# bless(..., "Venus::Enum") |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
# $get->value |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# "n" |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=back |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=over 4 |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item get example 2 |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
# given: synopsis |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
package main; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
my $get = $enum->get('s'); |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
# bless(..., "Venus::Enum") |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
# $get->value |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
# "s" |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=back |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=cut |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head2 has |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
has(string $name) (boolean) |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
The has method returns true if the member name or value exists in the enum, |
284
|
|
|
|
|
|
|
otherwise returns false. |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
I> |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=over 4 |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=item has example 1 |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
# given: synopsis |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
package main; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
my $has = $enum->has('n'); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
# true |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=back |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=over 4 |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=item has example 2 |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
# given: synopsis |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
package main; |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
my $has = $enum->has('z'); |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
# false |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=back |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=cut |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=head2 is |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
is(string $name) (boolean) |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
The is method returns true if the member name or value specified matches the |
323
|
|
|
|
|
|
|
member selected in the enum, otherwise returns false. |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
I> |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=over 4 |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=item is example 1 |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
# given: synopsis |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
package main; |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
my $is = $enum->get('n')->is('n'); |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
# true |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=back |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=over 4 |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
=item is example 2 |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
# given: synopsis |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
package main; |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
my $is = $enum->get('s')->is('n'); |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
# false |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=back |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
=cut |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
=head2 items |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
items() (tuple[string, string]) |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
The items method returns an arrayref of arrayrefs containing the name and value |
362
|
|
|
|
|
|
|
pairs for the enumerations. Returns a list in list context. |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
I> |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=over 4 |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=item items example 1 |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
# given: synopsis |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
package main; |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
my $items = $enum->items; |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
# [["e", "e"], ["n", "n"], ["s", "s"], ["w", "w"]] |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
=back |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
=over 4 |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=item items example 2 |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
# given: synopsis |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
package main; |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
my @items = $enum->items; |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
# (["e", "e"], ["n", "n"], ["s", "s"], ["w", "w"]) |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=back |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=cut |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=head2 list |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
list() (within[arrayref, string]) |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
The list method returns an arrayref containing the values for the enumerations. |
401
|
|
|
|
|
|
|
Returns a list in list context. |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
I> |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
=over 4 |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
=item list example 1 |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
# given: synopsis |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
package main; |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
my $list = $enum->list; |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
# ["e", "n", "s", "w"] |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=back |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
=over 4 |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=item list example 2 |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
# given: synopsis |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
package main; |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
my @list = $enum->list; |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
# ("e", "n", "s", "w") |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=back |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=cut |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=head2 name |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
name() (maybe[string]) |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
The name method returns the name of the member selected or returns undefined. |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
I> |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
=over 4 |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
=item name example 1 |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
# given: synopsis |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
package main; |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
my $name = $enum->name; |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
# undef |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=back |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=over 4 |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=item name example 2 |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
# given: synopsis |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
package main; |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
my $n = $enum->get('n'); |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
my $name = $n->name; |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
# "n" |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=back |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=cut |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=head2 names |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
names() (within[arrayref, string]) |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
The names method returns an arrayref containing the names for the enumerations. |
480
|
|
|
|
|
|
|
Returns a list in list context. |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
I> |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
=over 4 |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=item names example 1 |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
# given: synopsis |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
package main; |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
my $names = $enum->names; |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
# ["e", "n", "s", "w"] |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
=back |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=over 4 |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=item names example 2 |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
# given: synopsis |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
package main; |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
my @names = $enum->names; |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
# ("e", "n", "s", "w") |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=back |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=cut |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
=head2 value |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
value() (maybe[string]) |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
The value method returns the value of the member selected or returns undefined. |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
I> |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
=over 4 |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=item value example 1 |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
# given: synopsis |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
package main; |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
my $value = $enum->value; |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
# undef |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
=back |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=over 4 |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
=item value example 2 |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
# given: synopsis |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
package main; |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
my $n = $enum->get('n'); |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
my $value = $n->value; |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
# "n" |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
=back |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
=cut |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
=head2 values |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
values() (within[arrayref, string]) |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
The values method returns an arrayref containing the values for the |
559
|
|
|
|
|
|
|
enumerations. Returns a list in list context. |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
I> |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
=over 4 |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=item values example 1 |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
# given: synopsis |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
package main; |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
my $values = $enum->values; |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
# ["e", "n", "s", "w"] |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
=back |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
=over 4 |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=item values example 2 |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
# given: synopsis |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
package main; |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
my @values = $enum->values; |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
# ("e", "n", "s", "w") |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
=back |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
=cut |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
=head1 OPERATORS |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
This package overloads the following operators: |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=cut |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=over 4 |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
=item operation: C<("")> |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
This package overloads the C<""> operator. |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
B |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
# given: synopsis; |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
my $result = "$enum"; |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
# "" |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
B |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
# given: synopsis; |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
my $n = $enum->get("n"); |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
my $result = "$n"; |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
# "n" |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
=back |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
=over 4 |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
=item operation: C<(eq)> |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
This package overloads the C operator. |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
B |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
# given: synopsis; |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
my $result = $enum eq ""; |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
# 1 |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
B |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
# given: synopsis; |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
my $s = $enum->get("s"); |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
my $result = $s eq "s"; |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
# 1 |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
=back |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
=over 4 |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
=item operation: C<(ne)> |
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
This package overloads the C operator. |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
B |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
# given: synopsis; |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
my $result = $enum ne ""; |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
# 0 |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
B |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
# given: synopsis; |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
my $n = $enum->get("n"); |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
my $result = $n ne ""; |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
# 1 |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
=back |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
=over 4 |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=item operation: C<(qr)> |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
This package overloads the C operator. |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
B |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
# given: synopsis; |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
my $n = $enum->get('n'); |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
my $test = 'north' =~ qr/$n/; |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
# 1 |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
=back |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
=head1 AUTHORS |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
Awncorp, C |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
=cut |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
=head1 LICENSE |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
Copyright (C) 2000, Awncorp, C. |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
706
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
=cut |