line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Dump::Perl6; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
118099
|
use strict; |
|
13
|
|
|
|
|
63
|
|
|
13
|
|
|
|
|
417
|
|
4
|
13
|
|
|
13
|
|
58
|
use vars qw(@EXPORT @EXPORT_OK $VERSION $DEBUG); |
|
13
|
|
|
|
|
20
|
|
|
13
|
|
|
|
|
823
|
|
5
|
13
|
|
|
13
|
|
10380
|
use subs qq(dump); |
|
13
|
|
|
|
|
242
|
|
|
13
|
|
|
|
|
67
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
*import = \&Exporter::import; |
9
|
|
|
|
|
|
|
@EXPORT = qw(dd_perl6 ddx_perl6); |
10
|
|
|
|
|
|
|
@EXPORT_OK = qw(dump_perl6 pp_perl6 quote_perl6); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = "0.01"; |
13
|
|
|
|
|
|
|
$DEBUG = 0; |
14
|
|
|
|
|
|
|
|
15
|
13
|
|
|
13
|
|
36741
|
use overload (); |
|
13
|
|
|
|
|
13394
|
|
|
13
|
|
|
|
|
289
|
|
16
|
13
|
|
|
13
|
|
69
|
use Scalar::Util qw(blessed); |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
1285
|
|
17
|
13
|
|
|
13
|
|
59
|
use vars qw(%seen %refcnt @dump @fixup $INDENT $UTF8 $PARAM_NAME); |
|
13
|
|
|
|
|
21
|
|
|
13
|
|
|
|
|
17136
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$INDENT = " " unless defined $INDENT; |
20
|
|
|
|
|
|
|
$PARAM_NAME = 'content' unless defined $PARAM_NAME; |
21
|
|
|
|
|
|
|
$UTF8 = 0 unless defined $UTF8; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my %fh = ( |
24
|
|
|
|
|
|
|
'*main::STDIN' => '$*IN', |
25
|
|
|
|
|
|
|
'*main::STDOUT' => '$*OUT', |
26
|
|
|
|
|
|
|
'*main::STDERR' => '$*ERR', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub dump_perl6 { |
30
|
88
|
|
|
88
|
1
|
7152
|
local %seen; |
31
|
88
|
|
|
|
|
120
|
local %refcnt; |
32
|
88
|
|
|
|
|
127
|
local @fixup; |
33
|
|
|
|
|
|
|
|
34
|
88
|
|
|
|
|
117
|
my $name = "a"; |
35
|
88
|
|
|
|
|
101
|
my @dump; |
36
|
|
|
|
|
|
|
|
37
|
88
|
|
|
|
|
183
|
for my $v (@_) { |
38
|
126
|
|
|
|
|
286
|
my $val = _dump($v, $name, [], tied($v)); |
39
|
126
|
|
|
|
|
322
|
push(@dump, [$name, $val]); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
continue { |
42
|
126
|
|
|
|
|
227
|
$name++; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
88
|
|
|
|
|
116
|
my $out = ""; |
46
|
88
|
100
|
|
|
|
194
|
if (%refcnt) { |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# output all those with refcounts first |
49
|
5
|
|
|
|
|
11
|
for (@dump) { |
50
|
12
|
|
|
|
|
20
|
my $name = $_->[0]; |
51
|
12
|
100
|
|
|
|
37
|
if ($refcnt{$name}) { |
52
|
5
|
|
|
|
|
19
|
$out .= "my \$$name = $_->[1];\n"; |
53
|
5
|
|
|
|
|
12
|
undef $_->[1]; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
5
|
|
|
|
|
15
|
for (@fixup) { |
57
|
7
|
|
|
|
|
45
|
$out .= "$_;\n"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
88
|
|
|
|
|
153
|
my $paren = (@dump != 1); |
62
|
88
|
100
|
|
|
|
209
|
$out .= "(" if $paren; |
63
|
88
|
100
|
|
|
|
152
|
$out .= format_list($paren, undef, map { defined($_->[1]) ? $_->[1] : "\$" . $_->[0] } @dump); |
|
126
|
|
|
|
|
426
|
|
64
|
88
|
100
|
|
|
|
201
|
$out .= ")" if $paren; |
65
|
|
|
|
|
|
|
|
66
|
88
|
100
|
|
|
|
191
|
if (%refcnt) { |
67
|
5
|
|
|
|
|
10
|
$out .= ";\n"; |
68
|
5
|
|
|
|
|
51
|
$out =~ s/^/$INDENT/gm; |
69
|
5
|
|
|
|
|
15
|
$out = "do {\n$out}"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
88
|
50
|
|
|
|
184
|
print STDERR "$out\n" unless defined wantarray; |
73
|
88
|
|
|
|
|
741
|
$out; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
*pp_perl6 = \&dump_perl6; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub dd_perl6 { |
79
|
1
|
|
|
1
|
1
|
1094
|
print dump_perl6(@_), "\n"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub ddx_perl6 { |
83
|
2
|
|
|
2
|
1
|
26
|
my (undef, $file, $line) = caller; |
84
|
2
|
|
|
|
|
9
|
$file =~ s,.*[\\/],,; |
85
|
2
|
|
|
|
|
7
|
my $out = "$file:$line: " . dump_perl6(@_) . "\n"; |
86
|
2
|
|
|
|
|
24
|
$out =~ s/^/# /gm; |
87
|
2
|
|
|
|
|
64
|
print $out; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _dump { |
91
|
519
|
|
|
519
|
|
754
|
my $ref = ref $_[0]; |
92
|
519
|
100
|
|
|
|
967
|
my $rval = $ref ? $_[0] : \$_[0]; |
93
|
519
|
|
|
|
|
574
|
shift; |
94
|
|
|
|
|
|
|
|
95
|
519
|
|
|
|
|
723
|
my ($name, $idx, $dont_remember, $pclass, $pidx) = @_; |
96
|
|
|
|
|
|
|
|
97
|
519
|
|
|
|
|
533
|
my ($class, $type, $id); |
98
|
519
|
|
|
|
|
1143
|
my $strval = overload::StrVal($rval); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Parse $strval without using regexps, in order not to clobber $1, $2,... |
101
|
519
|
100
|
|
|
|
2323
|
if ((my $i = rindex($strval, "=")) >= 0) { |
102
|
18
|
|
|
|
|
33
|
$class = substr($strval, 0, $i); |
103
|
18
|
|
|
|
|
37
|
$strval = substr($strval, $i + 1); |
104
|
|
|
|
|
|
|
} |
105
|
519
|
50
|
|
|
|
993
|
if ((my $i = index($strval, "(0x")) >= 0) { |
106
|
519
|
|
|
|
|
711
|
$type = substr($strval, 0, $i); |
107
|
519
|
|
|
|
|
788
|
$id = substr($strval, $i + 2, -1); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
else { |
110
|
0
|
|
|
|
|
0
|
die "Can't parse " . overload::StrVal($rval); |
111
|
|
|
|
|
|
|
} |
112
|
519
|
50
|
33
|
|
|
1062
|
if ($] < 5.008 && $type eq "SCALAR") { |
113
|
0
|
0
|
|
|
|
0
|
$type = "REF" if $ref eq "REF"; |
114
|
|
|
|
|
|
|
} |
115
|
519
|
50
|
|
|
|
849
|
warn "\$$name(@$idx) $class $type $id ($ref)" if $DEBUG; |
116
|
|
|
|
|
|
|
|
117
|
519
|
|
|
|
|
576
|
my $out; |
118
|
|
|
|
|
|
|
my $comment; |
119
|
0
|
|
|
|
|
0
|
my $hide_keys; |
120
|
|
|
|
|
|
|
|
121
|
519
|
100
|
|
|
|
883
|
unless ($dont_remember) { |
122
|
507
|
100
|
|
|
|
1253
|
if (my $s = $seen{$id}) { |
123
|
11
|
|
|
|
|
20
|
my ($sname, $sidx) = @$s; |
124
|
11
|
|
|
|
|
19
|
$refcnt{$sname}++; |
125
|
11
|
|
100
|
|
|
53
|
my $sref = fullname($sname, $sidx, ($ref && $type eq "SCALAR")); |
126
|
11
|
50
|
|
|
|
29
|
warn "SEEN: [\$$name(@$idx)] => [\$$sname(@$sidx)] ($ref,$sref)" if $DEBUG; |
127
|
|
|
|
|
|
|
|
128
|
11
|
100
|
|
|
|
30
|
unless ($sname eq $name) { |
129
|
5
|
|
|
|
|
27
|
$sref =~ s/\.\Q$PARAM_NAME\E\z//; |
130
|
5
|
|
|
|
|
16
|
return $sref; |
131
|
|
|
|
|
|
|
} |
132
|
6
|
|
|
|
|
7
|
$refcnt{$name}++; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# Remove the "$PARAM_NAME" from blessed objects |
135
|
6
|
100
|
|
|
|
20
|
if (blessed($rval)) { |
136
|
2
|
|
|
|
|
35
|
$idx->[-1] =~ s/\.\Q$PARAM_NAME\E\z//; |
137
|
2
|
|
|
|
|
21
|
$sref =~ s/\.\Q$PARAM_NAME\E\z//; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
6
|
|
|
|
|
15
|
push(@fixup, fullname($name, $idx) . " = $sref"); |
141
|
6
|
50
|
33
|
|
|
30
|
return "do{my \$fix}" if @$idx && $idx->[-1] eq '$'; |
142
|
6
|
|
|
|
|
27
|
return "Any"; |
143
|
|
|
|
|
|
|
} |
144
|
496
|
|
|
|
|
1468
|
$seen{$id} = [$name, $idx]; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
508
|
100
|
|
|
|
880
|
if ($class) { |
148
|
16
|
|
|
|
|
20
|
$pclass = $class; |
149
|
16
|
|
|
|
|
22
|
$pidx = @$idx; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
508
|
50
|
100
|
|
|
2020
|
if (defined $out) { |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# keep it |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
elsif ($type eq "SCALAR" || $type eq "REF" || $type eq "REGEXP") { |
157
|
428
|
100
|
|
|
|
585
|
if ($ref) { |
158
|
15
|
50
|
66
|
|
|
55
|
if ($class && $class eq "Regexp") { |
159
|
0
|
|
|
|
|
0
|
die "Can't handle regular expressions for Perl6"; |
160
|
0
|
|
|
|
|
0
|
my $v = "$rval"; |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
0
|
my $mod = ""; |
163
|
0
|
0
|
|
|
|
0
|
if ($v =~ /^\(\?\^?([msix-]*):([\x00-\xFF]*)\)\z/) { |
164
|
0
|
|
|
|
|
0
|
$mod = $1; |
165
|
0
|
|
|
|
|
0
|
$v = $2; |
166
|
0
|
|
|
|
|
0
|
$mod =~ s/-.*//; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
0
|
my $sep = '/'; |
170
|
0
|
|
|
|
|
0
|
my $sep_count = ($v =~ tr/\///); |
171
|
0
|
0
|
|
|
|
0
|
if ($sep_count) { |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# see if we can find a better one |
174
|
0
|
|
|
|
|
0
|
for ('|', ',', ':') { |
175
|
0
|
|
|
|
|
0
|
my $c = eval "\$v =~ tr/\Q$_\E//"; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
#print "SEP $_ $c $sep_count\n"; |
178
|
0
|
0
|
|
|
|
0
|
if ($c < $sep_count) { |
179
|
0
|
|
|
|
|
0
|
$sep = $_; |
180
|
0
|
|
|
|
|
0
|
$sep_count = $c; |
181
|
0
|
0
|
|
|
|
0
|
last if $sep_count == 0; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
0
|
|
|
|
|
0
|
$v =~ s/\Q$sep\E/\\$sep/g; |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
0
|
$out = "rx$sep$v$sep$mod"; |
188
|
0
|
|
|
|
|
0
|
undef($class); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
else { |
191
|
15
|
100
|
|
|
|
54
|
delete $seen{$id} if $type eq "SCALAR"; # will be seen again shortly |
192
|
15
|
|
|
|
|
223
|
my $val = _dump($$rval, $name, [@$idx, ""], 0, $pclass, $pidx); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
#$out = $class ? "do{\\(my \$o = $val)}" : "\\($val)"; |
195
|
|
|
|
|
|
|
#$out = $class ? '' : "\\($val)"; |
196
|
15
|
|
|
|
|
35
|
$out = $val; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
else { |
200
|
413
|
100
|
|
|
|
658
|
if (!defined $$rval) { |
|
|
100
|
|
|
|
|
|
201
|
3
|
|
|
|
|
6
|
$out = "Nil"; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
elsif ( |
204
|
13
|
|
|
13
|
|
71
|
do { no warnings 'numeric'; $$rval + 0 eq $$rval } |
|
13
|
|
|
|
|
22
|
|
|
13
|
|
|
|
|
8679
|
|
|
410
|
|
|
|
|
4140
|
|
205
|
|
|
|
|
|
|
) { |
206
|
95
|
|
|
|
|
129
|
$out = $$rval; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
else { |
209
|
315
|
|
|
|
|
534
|
$out = str($$rval); |
210
|
|
|
|
|
|
|
} |
211
|
413
|
100
|
100
|
|
|
1070
|
if ($class && !@$idx) { |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# Top is an object, not a reference to one as perl needs |
214
|
1
|
|
|
|
|
2
|
$refcnt{$name}++; |
215
|
1
|
|
|
|
|
5
|
my $obj = fullname($name, $idx); |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
#my $cl = quote_perl6($class); |
218
|
|
|
|
|
|
|
#push(@fixup, "bless \\$obj, $cl"); |
219
|
1
|
|
|
|
|
5
|
push @fixup, "$class.bless($PARAM_NAME => $obj)"; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
elsif ($type eq "GLOB") { |
224
|
20
|
100
|
|
|
|
33
|
if ($ref) { |
225
|
1
|
|
|
|
|
3
|
delete $seen{$id}; |
226
|
1
|
|
|
|
|
26
|
my $val = _dump($$rval, $name, [@$idx, "*"], 0, $pclass, $pidx); |
227
|
|
|
|
|
|
|
|
228
|
1
|
50
|
|
|
|
3
|
if (exists $fh{$val}) { |
229
|
0
|
|
|
|
|
0
|
$out = $fh{$val}; |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
else { |
232
|
1
|
|
|
|
|
2
|
$out = $val; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
else { |
236
|
19
|
|
|
|
|
47
|
my $val = "$$rval"; |
237
|
19
|
|
|
|
|
39
|
$out = "$$rval"; |
238
|
|
|
|
|
|
|
|
239
|
19
|
100
|
|
|
|
41
|
if (exists $fh{$out}) { |
240
|
2
|
|
|
|
|
5
|
$out = $fh{$out}; |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
else { |
243
|
17
|
|
|
|
|
45
|
$out =~ s/^\*(?:main::)?//; |
244
|
17
|
|
|
|
|
36
|
$out = qq{IO::Handle.new(path => IO::Special.new(what => "<$out>"), ins => 0, chomp => Bool::True)}; |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
#die "Can't handle filehandles for Perl6" |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
elsif ($type eq "ARRAY") { |
251
|
19
|
|
|
|
|
23
|
my @vals; |
252
|
19
|
|
|
|
|
70
|
my $tied = tied_str(tied(@$rval)); |
253
|
19
|
|
|
|
|
25
|
my $i = 0; |
254
|
19
|
|
|
|
|
43
|
for my $v (@$rval) { |
255
|
291
|
100
|
|
|
|
1194
|
push(@vals, _dump($v, $name, [@$idx, "[$i]" . (blessed($v) ? ".$PARAM_NAME" : '')], $tied, $pclass, $pidx)); |
256
|
291
|
|
|
|
|
440
|
$i++; |
257
|
|
|
|
|
|
|
} |
258
|
19
|
|
|
|
|
59
|
$out = "[" . format_list(1, $tied, @vals) . "]"; |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
elsif ($type eq "HASH") { |
261
|
30
|
|
|
|
|
37
|
my (@keys, @vals); |
262
|
30
|
|
|
|
|
115
|
my $tied = tied_str(tied(%$rval)); |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# statistics to determine variation in key lengths |
265
|
30
|
|
|
|
|
53
|
my $kstat_max = 0; |
266
|
30
|
|
|
|
|
34
|
my $kstat_sum = 0; |
267
|
30
|
|
|
|
|
41
|
my $kstat_sum2 = 0; |
268
|
|
|
|
|
|
|
|
269
|
30
|
|
|
|
|
105
|
my @orig_keys = keys %$rval; |
270
|
30
|
50
|
|
|
|
88
|
if ($hide_keys) { |
271
|
0
|
|
|
|
|
0
|
@orig_keys = grep !$hide_keys->($_), @orig_keys; |
272
|
|
|
|
|
|
|
} |
273
|
30
|
|
|
|
|
39
|
my $text_keys = 0; |
274
|
30
|
|
|
|
|
54
|
for (@orig_keys) { |
275
|
32
|
100
|
|
|
|
148
|
$text_keys++, last unless /^[-+]?(?:0|[1-9]\d*)(?:\.\d+)?\z/; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
30
|
100
|
|
|
|
58
|
if ($text_keys) { |
279
|
25
|
50
|
|
|
|
72
|
@orig_keys = sort { (lc($a) cmp lc($b)) || ($a cmp $b) } @orig_keys; |
|
114
|
|
|
|
|
10437
|
|
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
else { |
282
|
5
|
|
|
|
|
8
|
@orig_keys = sort { $a <=> $b } @orig_keys; |
|
6
|
|
|
|
|
12
|
|
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
30
|
|
|
|
|
40
|
my $quote; |
286
|
30
|
|
|
|
|
51
|
for my $key (@orig_keys) { |
287
|
77
|
100
|
|
|
|
227
|
next if $key =~ /^[a-zA-Z_]\w*\z/; |
288
|
13
|
100
|
|
|
|
48
|
next if $key =~ /^[1-9]\d{0,8}\z/; |
289
|
|
|
|
|
|
|
|
290
|
9
|
100
|
|
|
|
27
|
if ($UTF8) { |
291
|
13
|
50
|
|
13
|
|
9974
|
next if $key =~ /^[\pL_][\pL\w]*\z/; |
|
13
|
|
|
|
|
112
|
|
|
13
|
|
|
|
|
178
|
|
|
4
|
|
|
|
|
47
|
|
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
5
|
|
|
|
|
7
|
$quote++; |
295
|
5
|
|
|
|
|
7
|
last; |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
30
|
|
|
|
|
54
|
for my $key (@orig_keys) { |
299
|
86
|
|
|
|
|
153
|
my $val = \$rval->{$key}; # capture value before we modify $key |
300
|
|
|
|
|
|
|
|
301
|
86
|
|
|
|
|
108
|
my $unquoted_key = $key; |
302
|
86
|
100
|
|
|
|
172
|
$key = quote_perl6($key) if $quote; |
303
|
86
|
100
|
|
|
|
172
|
$kstat_max = length($key) if length($key) > $kstat_max; |
304
|
86
|
|
|
|
|
189
|
$kstat_sum += length($key); |
305
|
86
|
|
|
|
|
120
|
$kstat_sum2 += length($key) * length($key); |
306
|
|
|
|
|
|
|
|
307
|
86
|
|
|
|
|
128
|
push(@keys, $key); |
308
|
|
|
|
|
|
|
|
309
|
86
|
|
|
|
|
128
|
$unquoted_key =~ s/([<>])/\\$1/g; |
310
|
86
|
100
|
|
|
|
537
|
push( |
311
|
|
|
|
|
|
|
@vals, |
312
|
|
|
|
|
|
|
_dump( |
313
|
|
|
|
|
|
|
$$val, $name, [@$idx, "<$unquoted_key>" . (blessed($$val) ? ".$PARAM_NAME" : '')], |
314
|
|
|
|
|
|
|
$tied, $pclass, $pidx |
315
|
|
|
|
|
|
|
) |
316
|
|
|
|
|
|
|
); |
317
|
|
|
|
|
|
|
} |
318
|
30
|
|
|
|
|
40
|
my $nl = ""; |
319
|
30
|
|
|
|
|
41
|
my $klen_pad = 0; |
320
|
30
|
|
|
|
|
124
|
my $tmp = "@keys @vals"; |
321
|
30
|
100
|
66
|
|
|
179
|
if (length($tmp) > 60 || $tmp =~ /\n/ || $tied) { |
|
|
|
100
|
|
|
|
|
322
|
14
|
|
|
|
|
19
|
$nl = "\n"; |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
# Determine what padding to add |
325
|
14
|
100
|
|
|
|
43
|
if ($kstat_max < 4) { |
|
|
100
|
|
|
|
|
|
326
|
5
|
|
|
|
|
10
|
$klen_pad = $kstat_max; |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
elsif (@keys >= 2) { |
329
|
6
|
|
|
|
|
9
|
my $n = @keys; |
330
|
6
|
|
|
|
|
16
|
my $avg = $kstat_sum / $n; |
331
|
6
|
|
|
|
|
19
|
my $stddev = sqrt(($kstat_sum2 - $n * $avg * $avg) / ($n - 1)); |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
# I am not actually very happy with this heuristics |
334
|
6
|
100
|
|
|
|
16
|
if ($stddev / $kstat_max < 0.25) { |
335
|
3
|
|
|
|
|
4
|
$klen_pad = $kstat_max; |
336
|
|
|
|
|
|
|
} |
337
|
6
|
50
|
|
|
|
15
|
if ($DEBUG) { |
338
|
0
|
|
|
|
|
0
|
push(@keys, "__S"); |
339
|
0
|
|
|
|
|
0
|
push(@vals, sprintf("%.2f (%d/%.1f/%.1f)", $stddev / $kstat_max, $kstat_max, $avg, $stddev)); |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
} |
343
|
30
|
|
|
|
|
52
|
$out = "{$nl"; |
344
|
30
|
100
|
|
|
|
56
|
$out .= "$INDENT# $tied$nl" if $tied; |
345
|
30
|
|
|
|
|
70
|
while (@keys) { |
346
|
86
|
|
|
|
|
116
|
my $key = shift @keys; |
347
|
86
|
|
|
|
|
115
|
my $val = shift @vals; |
348
|
86
|
100
|
|
|
|
210
|
my $vpad = $INDENT . (" " x ($klen_pad ? $klen_pad + 4 : 0)); |
349
|
86
|
|
|
|
|
155
|
$val =~ s/\n/\n$vpad/gm; |
350
|
86
|
100
|
|
|
|
193
|
my $kpad = $nl ? $INDENT : " "; |
351
|
86
|
100
|
100
|
|
|
304
|
$key .= " " x ($klen_pad - length($key)) if $nl && $klen_pad > length($key); |
352
|
86
|
|
|
|
|
300
|
$out .= "$kpad$key => $val,$nl"; |
353
|
|
|
|
|
|
|
} |
354
|
30
|
100
|
|
|
|
105
|
$out =~ s/,$/ / unless $nl; |
355
|
30
|
|
|
|
|
82
|
$out .= "}"; |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
elsif ($type eq "CODE") { |
358
|
0
|
|
|
|
|
0
|
$out = 'sub { ... }'; |
359
|
|
|
|
|
|
|
} |
360
|
|
|
|
|
|
|
elsif ($type eq "VSTRING") { |
361
|
11
|
|
|
|
|
32
|
$out = sprintf 'v%vd', $$rval; |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
else { |
364
|
0
|
|
|
|
|
0
|
warn "Can't handle $type data"; |
365
|
0
|
|
|
|
|
0
|
$out = "'#$type#'"; |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
508
|
100
|
100
|
|
|
992
|
if ($class && $ref) { |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
# Class must be something like 'Class::Name' |
371
|
12
|
50
|
|
|
|
62
|
if ($class !~ /^[\pL_][\pL\d_]*(?:::[\pL\d_]+)*\z/) { |
372
|
0
|
|
|
|
|
0
|
die "Can't handle class name <$class> for Perl6"; |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
|
375
|
12
|
|
|
|
|
34
|
$out = "$class.bless($PARAM_NAME => $out)"; |
376
|
|
|
|
|
|
|
} |
377
|
508
|
50
|
|
|
|
806
|
if ($comment) { |
378
|
0
|
|
|
|
|
0
|
$comment =~ s/^/# /gm; |
379
|
0
|
0
|
|
|
|
0
|
$comment .= "\n" unless $comment =~ /\n\z/; |
380
|
0
|
|
|
|
|
0
|
$comment =~ s/^#[ \t]+\n/\n/; |
381
|
0
|
|
|
|
|
0
|
$out = "$comment$out"; |
382
|
|
|
|
|
|
|
} |
383
|
508
|
|
|
|
|
1201
|
return $out; |
384
|
|
|
|
|
|
|
} |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
sub tied_str { |
387
|
49
|
|
|
49
|
0
|
66
|
my $tied = shift; |
388
|
49
|
100
|
|
|
|
94
|
if ($tied) { |
389
|
2
|
50
|
|
|
|
6
|
if (my $tied_ref = ref($tied)) { |
390
|
2
|
|
|
|
|
5
|
$tied = "tied $tied_ref"; |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
else { |
393
|
0
|
|
|
|
|
0
|
$tied = "tied"; |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
} |
396
|
49
|
|
|
|
|
77
|
return $tied; |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
sub fullname { |
400
|
18
|
|
|
18
|
0
|
28
|
my ($name, $idx, $ref) = @_; |
401
|
18
|
|
|
|
|
32
|
substr($name, 0, 0) = "\$"; |
402
|
|
|
|
|
|
|
|
403
|
18
|
|
|
|
|
35
|
my @i = @$idx; # need copy in order to not modify @$idx |
404
|
18
|
50
|
100
|
|
|
65
|
if ($ref && @i && $i[0] eq "\$") { |
|
|
|
66
|
|
|
|
|
405
|
0
|
|
|
|
|
0
|
shift(@i); # remove one deref |
406
|
0
|
|
|
|
|
0
|
$ref = 0; |
407
|
|
|
|
|
|
|
} |
408
|
18
|
|
66
|
|
|
80
|
while (@i && $i[0] eq "\$") { # this will never happen |
409
|
0
|
|
|
|
|
0
|
shift @i; |
410
|
0
|
|
|
|
|
0
|
$name = "\$($name)"; |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
|
413
|
18
|
|
|
|
|
22
|
my $last_was_index; |
414
|
18
|
|
|
|
|
29
|
for my $i (@i) { |
415
|
22
|
50
|
33
|
|
|
108
|
if ($i eq "*" || $i eq "\$") { |
|
|
50
|
|
|
|
|
|
416
|
0
|
|
|
|
|
0
|
$last_was_index = 0; |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
#$name = "$i\{$name}"; |
419
|
|
|
|
|
|
|
#$name = "$i$name"; |
420
|
0
|
|
|
|
|
0
|
$name = "$i\($name)"; |
421
|
|
|
|
|
|
|
} |
422
|
|
|
|
|
|
|
elsif ($i =~ s/^\*//) { |
423
|
0
|
|
|
|
|
0
|
$name .= $i; |
424
|
0
|
|
|
|
|
0
|
$last_was_index++; |
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
else { |
427
|
|
|
|
|
|
|
#$name .= "->" unless $last_was_index++; |
428
|
22
|
|
|
|
|
35
|
$name .= $i; |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
#$name = "\\($name)" if $ref; |
433
|
18
|
|
|
|
|
53
|
$name; |
434
|
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
sub format_list { |
437
|
107
|
|
|
107
|
0
|
152
|
my $paren = shift; |
438
|
107
|
|
|
|
|
124
|
my $comment = shift; |
439
|
107
|
100
|
|
|
|
177
|
my $indent_lim = $paren ? 0 : 1; |
440
|
107
|
100
|
|
|
|
230
|
if (@_ > 3) { |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
# can we use range operator to shorten the list? |
443
|
9
|
|
|
|
|
12
|
my $i = 0; |
444
|
9
|
|
|
|
|
25
|
while ($i < @_) { |
445
|
28
|
|
|
|
|
32
|
my $j = $i + 1; |
446
|
28
|
|
|
|
|
35
|
my $v = $_[$i]; |
447
|
28
|
|
|
|
|
58
|
while ($j < @_) { |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
# XXX allow string increment too? |
450
|
307
|
100
|
100
|
|
|
1636
|
if ($v eq "0" || $v =~ /^-?[1-9]\d{0,9}\z/) { |
|
|
100
|
|
|
|
|
|
451
|
37
|
|
|
|
|
46
|
$v++; |
452
|
|
|
|
|
|
|
} |
453
|
|
|
|
|
|
|
elsif ($v =~ /^"([A-Za-z]{1,3}\d*)"\z/) { |
454
|
266
|
|
|
|
|
368
|
$v = $1; |
455
|
266
|
|
|
|
|
257
|
$v++; |
456
|
266
|
|
|
|
|
339
|
$v = qq("$v"); |
457
|
|
|
|
|
|
|
} |
458
|
|
|
|
|
|
|
else { |
459
|
4
|
|
|
|
|
4
|
last; |
460
|
|
|
|
|
|
|
} |
461
|
303
|
100
|
|
|
|
553
|
last if $_[$j] ne $v; |
462
|
289
|
|
|
|
|
496
|
$j++; |
463
|
|
|
|
|
|
|
} |
464
|
28
|
100
|
|
|
|
54
|
if ($j - $i > 3) { |
465
|
9
|
|
|
|
|
34
|
splice(@_, $i, $j - $i, "$_[$i] .. $_[$j-1]"); |
466
|
|
|
|
|
|
|
} |
467
|
28
|
|
|
|
|
60
|
$i++; |
468
|
|
|
|
|
|
|
} |
469
|
|
|
|
|
|
|
} |
470
|
107
|
|
|
|
|
226
|
my $tmp = "@_"; |
471
|
107
|
100
|
66
|
|
|
516
|
if ($comment || (@_ > $indent_lim && (length($tmp) > 60 || $tmp =~ /\n/))) { |
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
472
|
5
|
|
|
|
|
12
|
my @elem = @_; |
473
|
5
|
|
|
|
|
32
|
for (@elem) { s/^/$INDENT/gm; } |
|
6
|
|
|
|
|
46
|
|
474
|
5
|
100
|
|
|
|
41
|
return "\n" . ($comment ? "$INDENT# $comment\n" : "") . join(",\n", @elem, ""); |
475
|
|
|
|
|
|
|
} |
476
|
|
|
|
|
|
|
else { |
477
|
102
|
|
|
|
|
311
|
return join(", ", @_); |
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
sub str { |
482
|
315
|
100
|
|
315
|
0
|
587
|
if (length($_[0]) > 20) { |
483
|
11
|
|
|
|
|
25
|
for ($_[0]) { |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
# Check for repeated string |
486
|
11
|
100
|
|
|
|
46
|
if (/^(.)\1\1\1/s) { |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
# seems to be a repeating sequence, let's check if it really is |
489
|
|
|
|
|
|
|
# without backtracking |
490
|
4
|
50
|
|
|
|
60296
|
unless (/[^\Q$1\E]/) { |
491
|
4
|
|
|
|
|
15
|
my $base = quote_perl6($1); |
492
|
4
|
|
|
|
|
9
|
my $repeat = length; |
493
|
4
|
|
|
|
|
24
|
return "($base x $repeat)"; |
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
# Length protection because the RE engine will blow the stack [RT#33520] |
498
|
7
|
100
|
66
|
|
|
95
|
if (length($_) < 16 * 1024 && /^(.{2,5}?)\1*\z/s) { |
499
|
2
|
|
|
|
|
6
|
my $base = quote_perl6($1); |
500
|
2
|
|
|
|
|
7
|
my $repeat = length($_) / length($1); |
501
|
2
|
|
|
|
|
25
|
return "($base x $repeat)"; |
502
|
|
|
|
|
|
|
} |
503
|
|
|
|
|
|
|
} |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
|
506
|
309
|
|
|
|
|
439
|
scalar "e_perl6; |
507
|
|
|
|
|
|
|
} |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
my %esc = ( |
510
|
|
|
|
|
|
|
"\a" => "\\a", |
511
|
|
|
|
|
|
|
"\b" => "\\b", |
512
|
|
|
|
|
|
|
"\t" => "\\t", |
513
|
|
|
|
|
|
|
"\n" => "\\n", |
514
|
|
|
|
|
|
|
"\f" => "\\f", |
515
|
|
|
|
|
|
|
"\r" => "\\r", |
516
|
|
|
|
|
|
|
"\e" => "\\e", |
517
|
|
|
|
|
|
|
); |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
# put a string value in double quotes |
520
|
|
|
|
|
|
|
sub quote_perl6 { |
521
|
348
|
|
|
348
|
1
|
621
|
local ($_) = $_[0]; |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
# If there are many '"' we might want to use qq() instead |
524
|
348
|
|
|
|
|
567
|
s/([\\\"\@\${}])/\\$1/g; |
525
|
348
|
100
|
|
|
|
1251
|
return qq("$_") unless /[^\040-\176]/; # fast exit |
526
|
|
|
|
|
|
|
|
527
|
18
|
|
|
|
|
85
|
s/([\a\b\t\n\f\r\e])/$esc{$1}/g; |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
# no need for 3 digits in escape for these |
530
|
|
|
|
|
|
|
#s/([\0-\037])(?!\d)/sprintf('\\%o',ord($1))/eg; |
531
|
|
|
|
|
|
|
|
532
|
18
|
|
|
|
|
41
|
s/([\0-\037])/sprintf('\\x[%x]',ord($1))/eg; |
|
1054
|
|
|
|
|
2281
|
|
533
|
|
|
|
|
|
|
|
534
|
18
|
100
|
|
|
|
38
|
if ($UTF8) { |
535
|
5
|
|
|
|
|
38
|
s/([^\pL\pN\pM\pP\pS\040-\176])/sprintf('\\x[%x]',ord($1))/eg; |
|
0
|
|
|
|
|
0
|
|
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
else { |
538
|
13
|
|
|
|
|
65
|
s/([\177-\377])/sprintf('\\x[%x]',ord($1))/eg; |
|
134
|
|
|
|
|
297
|
|
539
|
13
|
|
|
|
|
108
|
s/([^\040-\176])/sprintf('\\x[%x]',ord($1))/eg; |
|
105
|
|
|
|
|
251
|
|
540
|
|
|
|
|
|
|
} |
541
|
|
|
|
|
|
|
|
542
|
18
|
|
|
|
|
146
|
return qq("$_"); |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
1; |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=encoding utf8 |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=head1 NAME |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
Data::Dump::Perl6 - Pretty printing of data structures as Perl6 code |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=head1 SYNOPSIS |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
use Data::Dump::Perl6 qw(dump_perl6); |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
$str = dump_perl6(@list); |
558
|
|
|
|
|
|
|
print "$str\n"; |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
=head1 DESCRIPTION |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
This module provide functions that takes a list of values as their |
563
|
|
|
|
|
|
|
argument and produces a string as its result. The string contains Perl6 |
564
|
|
|
|
|
|
|
code that, when interpreted by perl6, produces a deep copy of the original |
565
|
|
|
|
|
|
|
arguments. |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
The main feature of the module is that it strives to produce output |
568
|
|
|
|
|
|
|
that is easy to read. Example: |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
@a = (1, [2, 3], {4 => 5}); |
571
|
|
|
|
|
|
|
dump_perl6(@a); |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
Produces: |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
"(1, [2, 3], { 4 => 5 })" |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
If you dump just a little data, it is output on a single line. If |
578
|
|
|
|
|
|
|
you dump data that is more complex or there is a lot of it, line breaks |
579
|
|
|
|
|
|
|
are automatically added to keep it easy to read. |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
The following functions are provided (only the dd* functions are exported by default): |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
=over |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
=item dump_perl6( ... ) |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=item pp_perl6( ... ) |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
If you call the function with multiple arguments then the output will |
590
|
|
|
|
|
|
|
be wrapped in parenthesis "( ..., ... )". If you call the function with a |
591
|
|
|
|
|
|
|
single argument the output will not have the wrapping. If you call the function with |
592
|
|
|
|
|
|
|
a single scalar (non-reference) argument it will just return the |
593
|
|
|
|
|
|
|
scalar quoted if needed, but never break it into multiple lines. If you |
594
|
|
|
|
|
|
|
pass multiple arguments or references to arrays of hashes then the |
595
|
|
|
|
|
|
|
return value might contain line breaks to format it for easier |
596
|
|
|
|
|
|
|
reading. The returned string will never be "\n" terminated, even if |
597
|
|
|
|
|
|
|
contains multiple lines. This allows code like this to place the |
598
|
|
|
|
|
|
|
semicolon in the expected place: |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
print '$obj = ', dump_perl6($obj), ";\n"; |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
If dump_perl6() is called in void context, then the dump is printed on |
603
|
|
|
|
|
|
|
STDERR and then "\n" terminated. You might find this useful for quick |
604
|
|
|
|
|
|
|
debug printouts, but the dd*() functions might be better alternatives |
605
|
|
|
|
|
|
|
for this. |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
There is no difference between dump_perl6() and pp_perl6(). |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=item quote_perl6( $string ) |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
Returns a quoted version of the provided string. |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
It differs from C in that it will quote even numbers |
614
|
|
|
|
|
|
|
and not try to come up with clever expressions that might shorten the |
615
|
|
|
|
|
|
|
output. If a non-scalar argument is provided then it's just stringified |
616
|
|
|
|
|
|
|
instead of traversed. |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
=item dd_perl6( ... ) |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
=item ddx_perl6( ... ) |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
These functions will call dump_perl6() on their argument and print the |
623
|
|
|
|
|
|
|
result to STDOUT (actually, it's the currently selected output handle, but |
624
|
|
|
|
|
|
|
STDOUT is the default for that). |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
The difference between them is only that ddx_perl6() will prefix the |
627
|
|
|
|
|
|
|
lines it prints with "# " and mark the first line with the file and |
628
|
|
|
|
|
|
|
line number where it was called. This is meant to be useful for debug |
629
|
|
|
|
|
|
|
printouts of state within programs. |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
=back |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
=head1 CONFIGURATION |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
There are a few global variables that can be set to modify the output |
636
|
|
|
|
|
|
|
generated by the dump functions. It's wise to localize the setting of |
637
|
|
|
|
|
|
|
these. |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
=over |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
=item $Data::Dump::Perl6::INDENT |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
This holds the string that's used for indenting multiline data structures. |
644
|
|
|
|
|
|
|
It's default value is " " (two spaces). Set it to "" to suppress indentation. |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
=item $Data::Dump::Perl6::UTF8 |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
A true value will dump strings with original Unicode letters, symbols, numbers |
649
|
|
|
|
|
|
|
and marks. By default, hexadecimal escapes are used for non-ASCII code points. |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
=item $Data::Dump::Perl6::PARAM_NAME |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
This holds the name of a class parameter, which is used in creating Perl6 |
654
|
|
|
|
|
|
|
blessed objects. The default value is C. |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
Example: |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
bless([], "Foo") |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
is dumped as: |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
Foo.bless(content => []) |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=back |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
=head1 BUGS/LIMITATIONS |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
Code references will be dumped as C<< sub { ... } >>. |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
Regular expressions are currently unsupported. An exception will be |
671
|
|
|
|
|
|
|
thrown when any regular expression is encountered. |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
Filehandles are limited to C, C and C. |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
Class names cannot contain punctuation marks. |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
=head1 SEE ALSO |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
L (from which this codebase is based) |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
L, L - Another alternative to exchange data with Perl6 (and |
682
|
|
|
|
|
|
|
other languages) is to export/import via YAML and JSON. |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
Data::Dump::Perl6 is a quick hack, based on Gisle Ass' wonderful C. |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=head1 REPOSITORY |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
L |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
=head1 AUTHORS |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
The C module is written by Daniel Șuteu |
695
|
|
|
|
|
|
|
, based on C module by Gisle Aas |
696
|
|
|
|
|
|
|
, based on C by Gurusamy Sarathy |
697
|
|
|
|
|
|
|
. |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
Copyright 2015 Daniel Șuteu. |
700
|
|
|
|
|
|
|
Copyright 1998-2010 Gisle Aas. |
701
|
|
|
|
|
|
|
Copyright 1996-1998 Gurusamy Sarathy. |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or |
704
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
=cut |