line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Role::Printable; |
2
|
|
|
|
|
|
|
|
3
|
87
|
|
|
87
|
|
1433
|
use 5.018; |
|
87
|
|
|
|
|
283
|
|
4
|
|
|
|
|
|
|
|
5
|
87
|
|
|
87
|
|
477
|
use strict; |
|
87
|
|
|
|
|
202
|
|
|
87
|
|
|
|
|
1736
|
|
6
|
87
|
|
|
87
|
|
418
|
use warnings; |
|
87
|
|
|
|
|
208
|
|
|
87
|
|
|
|
|
2758
|
|
7
|
|
|
|
|
|
|
|
8
|
87
|
|
|
87
|
|
559
|
use Venus::Role 'fault'; |
|
87
|
|
|
|
|
232
|
|
|
87
|
|
|
|
|
570
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# AUDITS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub AUDIT { |
13
|
88
|
|
|
88
|
0
|
250
|
my ($self, $from) = @_; |
14
|
|
|
|
|
|
|
|
15
|
88
|
50
|
|
|
|
409
|
if (!$from->does('Venus::Role::Dumpable')) { |
16
|
0
|
|
|
|
|
0
|
fault "${self} requires ${from} to consume Venus::Role::Dumpable"; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
88
|
|
|
|
|
262
|
return $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# METHODS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub print { |
25
|
2
|
|
|
2
|
1
|
10
|
my ($self, @args) = @_; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
11
|
return $self->printer($self->dump(@args)); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub print_json { |
31
|
2
|
|
|
2
|
1
|
9
|
my ($self, $method, @args) = @_; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
9
|
require Venus::Json; |
34
|
|
|
|
|
|
|
|
35
|
2
|
100
|
|
|
|
28
|
my $value = $method ? scalar($self->$method(@args)) : $self; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
7
|
require Scalar::Util; |
38
|
|
|
|
|
|
|
|
39
|
2
|
100
|
|
|
|
10
|
if (Scalar::Util::blessed($value)) { |
40
|
1
|
50
|
|
|
|
8
|
$value = $value->value if $value->isa('Venus::Kind'); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
15
|
return $self->printer(Venus::Json->new($value)->encode); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub print_pretty { |
47
|
2
|
|
|
2
|
1
|
7
|
my ($self, @args) = @_; |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
12
|
return $self->printer($self->dump_pretty(@args)); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub print_string { |
53
|
1
|
|
|
1
|
1
|
5
|
my ($self, $method, @args) = @_; |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
3
|
local $_ = $self; |
56
|
|
|
|
|
|
|
|
57
|
1
|
50
|
|
|
|
22
|
return $self->printer($method ? scalar($self->$method(@args)) : $self); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub print_yaml { |
61
|
0
|
|
|
0
|
1
|
0
|
my ($self, $method, @args) = @_; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
0
|
require Venus::Yaml; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
0
|
my $value = $method ? scalar($self->$method(@args)) : $self; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
require Scalar::Util; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
0
|
if (Scalar::Util::blessed($value)) { |
70
|
0
|
0
|
|
|
|
0
|
$value = $value->value if $value->isa('Venus::Kind'); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
0
|
return $self->printer(Venus::Yaml->new($value)->encode); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub printer { |
77
|
0
|
|
|
0
|
0
|
0
|
my ($self, @args) = @_; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
return CORE::print(STDOUT @args); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub say { |
83
|
2
|
|
|
2
|
1
|
6
|
my ($self, @args) = @_; |
84
|
|
|
|
|
|
|
|
85
|
2
|
|
|
|
|
8
|
return $self->printer($self->dump(@args), "\n"); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub say_json { |
89
|
2
|
|
|
2
|
1
|
6
|
my ($self, $method, @args) = @_; |
90
|
|
|
|
|
|
|
|
91
|
2
|
|
|
|
|
9
|
require Venus::Json; |
92
|
|
|
|
|
|
|
|
93
|
2
|
100
|
|
|
|
25
|
my $value = $method ? scalar($self->$method(@args)) : $self; |
94
|
|
|
|
|
|
|
|
95
|
2
|
|
|
|
|
9
|
require Scalar::Util; |
96
|
|
|
|
|
|
|
|
97
|
2
|
100
|
|
|
|
12
|
if (Scalar::Util::blessed($value)) { |
98
|
1
|
50
|
|
|
|
8
|
$value = $value->value if $value->isa('Venus::Kind'); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
2
|
|
|
|
|
8
|
return $self->printer(Venus::Json->new($value)->encode, "\n"); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub say_pretty { |
105
|
2
|
|
|
2
|
1
|
8
|
my ($self, @args) = @_; |
106
|
|
|
|
|
|
|
|
107
|
2
|
|
|
|
|
8
|
return $self->printer($self->dump_pretty(@args), "\n"); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub say_string { |
111
|
1
|
|
|
1
|
1
|
4
|
my ($self, $method, @args) = @_; |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
3
|
local $_ = $self; |
114
|
|
|
|
|
|
|
|
115
|
1
|
50
|
|
|
|
20
|
return $self->printer(($method ? scalar($self->$method(@args)) : $self), "\n"); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub say_yaml { |
119
|
0
|
|
|
0
|
1
|
0
|
my ($self, $method, @args) = @_; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
0
|
require Venus::Yaml; |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
0
|
my $value = $method ? scalar($self->$method(@args)) : $self; |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
0
|
require Scalar::Util; |
126
|
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
0
|
if (Scalar::Util::blessed($value)) { |
128
|
0
|
0
|
|
|
|
0
|
$value = $value->value if $value->isa('Venus::Kind'); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
0
|
return $self->printer(Venus::Yaml->new($value)->encode, "\n"); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# EXPORTS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub EXPORT { |
137
|
|
|
|
|
|
|
[ |
138
|
88
|
|
|
88
|
0
|
425
|
'print', |
139
|
|
|
|
|
|
|
'print_json', |
140
|
|
|
|
|
|
|
'print_pretty', |
141
|
|
|
|
|
|
|
'print_string', |
142
|
|
|
|
|
|
|
'print_yaml', |
143
|
|
|
|
|
|
|
'printer', |
144
|
|
|
|
|
|
|
'say', |
145
|
|
|
|
|
|
|
'say_json', |
146
|
|
|
|
|
|
|
'say_pretty', |
147
|
|
|
|
|
|
|
'say_string', |
148
|
|
|
|
|
|
|
'say_yaml', |
149
|
|
|
|
|
|
|
] |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 NAME |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Venus::Role::Printable - Printable Role |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 ABSTRACT |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Printable Role for Perl 5 |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 SYNOPSIS |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
package Example; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
use Venus::Class; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
with 'Venus::Role::Dumpable'; |
175
|
|
|
|
|
|
|
with 'Venus::Role::Printable'; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
attr 'test'; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub execute { |
180
|
|
|
|
|
|
|
return [@_]; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub printer { |
184
|
|
|
|
|
|
|
return [@_]; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
package main; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# $example->say; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 DESCRIPTION |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
This package provides a mechanism for outputting (printing) objects or the |
198
|
|
|
|
|
|
|
return value of a dispatched method call to STDOUT. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=cut |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 METHODS |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This package provides the following methods: |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 print |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
print(Any @data) (Any) |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
The print method prints a stringified representation of the underlying data. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
I> |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=over 4 |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item print example 1 |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
package main; |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
my $print = $example->print; |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# bless({test => 123}, 'Example') |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
# 1 |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=back |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=over 4 |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item print example 2 |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
package main; |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
my $print = $example->print('execute', 1, 2, 3); |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# [bless({test => 123}, 'Example'),1,2,3] |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
# 1 |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=back |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=cut |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head2 print_json |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
print_json(Str | CodeRef $method, Any @args) (Any) |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
The print_json method prints a JSON representation of the underlying data. This |
255
|
|
|
|
|
|
|
method supports dispatching, i.e. providing a method name and arguments whose |
256
|
|
|
|
|
|
|
return value will be acted on by this method. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
I> |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=over 4 |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=item print_json example 1 |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
package main; |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
my $print_json = $example->print_json; |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
# "{\"test\": 123}" |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=back |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=over 4 |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=item print_json example 2 |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
package main; |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
my $print_json = $example->print_json('execute'); |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
# "[{\"test\": 123}]" |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=back |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=cut |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=head2 print_pretty |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
print_pretty(Any @data) (Any) |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
The print_pretty method prints a stringified human-readable representation of |
295
|
|
|
|
|
|
|
the underlying data. |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
I> |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=over 4 |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=item print_pretty example 1 |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
package main; |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
my $print_pretty = $example->print_pretty; |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
# bless({ test => 123 }, 'Example') |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
# 1 |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=back |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=over 4 |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=item print_pretty example 2 |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
package main; |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
my $print_pretty = $example->print_pretty('execute', 1, 2, 3); |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
# [ |
326
|
|
|
|
|
|
|
# bless({ test => 123 }, 'Example'), |
327
|
|
|
|
|
|
|
# 1, |
328
|
|
|
|
|
|
|
# 2, |
329
|
|
|
|
|
|
|
# 3 |
330
|
|
|
|
|
|
|
# ] |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
# 1 |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
=back |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
=cut |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=head2 print_string |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
print_string(Str | CodeRef $method, Any @args) (Any) |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
The print_string method prints a string representation of the underlying data |
343
|
|
|
|
|
|
|
without using a dump. This method supports dispatching, i.e. providing a |
344
|
|
|
|
|
|
|
method name and arguments whose return value will be acted on by this method. |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
I> |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
=over 4 |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
=item print_string example 1 |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
package main; |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
my $print_string = $example->print_string; |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
# 'Example' |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
# 1 |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
=back |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
=cut |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=head2 print_yaml |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
print_yaml(Str | CodeRef $method, Any @args) (Any) |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
The print_yaml method prints a YAML representation of the underlying data. This |
371
|
|
|
|
|
|
|
method supports dispatching, i.e. providing a method name and arguments whose |
372
|
|
|
|
|
|
|
return value will be acted on by this method. |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
I> |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=over 4 |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
=item print_yaml example 1 |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
package main; |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
my $print_yaml = $example->print_yaml; |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
# "---\ntest: 123" |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
=back |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=over 4 |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=item print_yaml example 2 |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
package main; |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
my $print_yaml = $example->print_yaml('execute'); |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
# "---\n- test: 123" |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=back |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=cut |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
=head2 say |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
say(Any @data) (Any) |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
The say method prints a stringified representation of the underlying data, with |
411
|
|
|
|
|
|
|
a trailing newline. |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
I> |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=over 4 |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=item say example 1 |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
package main; |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
my $say = $example->say; |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
# bless({test => 123}, 'Example')\n |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
# 1 |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
=back |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=over 4 |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=item say example 2 |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
package main; |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
my $say = $example->say; |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
# [bless({test => 123}, 'Example'),1,2,3]\n |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
# 1 |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
=back |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=cut |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=head2 say_json |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
say_json(Str | CodeRef $method, Any @args) (Any) |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
The say_json method prints a JSON representation of the underlying data. This |
454
|
|
|
|
|
|
|
method supports dispatching, i.e. providing a method name and arguments whose |
455
|
|
|
|
|
|
|
return value will be acted on by this method, with a trailing newline. |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
I> |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=over 4 |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
=item say_json example 1 |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
package main; |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
my $say_json = $example->say_json; |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
# "{\"test\": 123}\n" |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=back |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=over 4 |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=item say_json example 2 |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
package main; |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
my $say_json = $example->say_json('execute'); |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
# "[{\"test\": 123}]\n" |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
=back |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
=cut |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
=head2 say_pretty |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
say_pretty(Any @data) (Any) |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
The say_pretty method prints a stringified human-readable representation of the |
494
|
|
|
|
|
|
|
underlying data, with a trailing newline. |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
I> |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=over 4 |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=item say_pretty example 1 |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
package main; |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
my $say_pretty = $example->say_pretty; |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
# bless({ test => 123 }, 'Example')\n |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
# 1 |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=back |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
=over 4 |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=item say_pretty example 2 |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
package main; |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
my $say_pretty = $example->say_pretty; |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
# [ |
525
|
|
|
|
|
|
|
# bless({ test => 123 }, 'Example'), |
526
|
|
|
|
|
|
|
# 1, |
527
|
|
|
|
|
|
|
# 2, |
528
|
|
|
|
|
|
|
# 3 |
529
|
|
|
|
|
|
|
# ]\n |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
# 1 |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=back |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=cut |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
=head2 say_string |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
say_string(Str | CodeRef $method, Any @args) (Any) |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
The say_string method prints a string representation of the underlying data |
542
|
|
|
|
|
|
|
without using a dump, with a trailing newline. This method supports |
543
|
|
|
|
|
|
|
dispatching, i.e. providing a method name and arguments whose return value will |
544
|
|
|
|
|
|
|
be acted on by this method. |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
I> |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
=over 4 |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
=item say_string example 1 |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
package main; |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
my $say_string = $example->say_string; |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
# "Example\n" |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
# 1 |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
=back |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
=cut |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=head2 say_yaml |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
say_yaml(Str | CodeRef $method, Any @args) (Any) |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
The say_yaml method prints a YAML representation of the underlying data. This |
571
|
|
|
|
|
|
|
method supports dispatching, i.e. providing a method name and arguments whose |
572
|
|
|
|
|
|
|
return value will be acted on by this method, with a trailing newline. |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
I> |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
=over 4 |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
=item say_yaml example 1 |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
package main; |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
my $say_yaml = $example->say_yaml; |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
# "---\ntest: 123\n" |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
=back |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
=over 4 |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
=item say_yaml example 2 |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
package main; |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
my $example = Example->new(test => 123); |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
my $say_yaml = $example->say_yaml('execute'); |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
# "---\n- test: 123\n" |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
=back |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
=cut |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
=head1 AUTHORS |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
Awncorp, C |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
=cut |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
=head1 LICENSE |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
617
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=cut |