| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::VarPrint; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.000; |
|
4
|
|
|
|
|
|
|
require Exporter; |
|
5
|
|
|
|
|
|
|
require AutoLoader; |
|
6
|
1
|
|
|
1
|
|
414699
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
83
|
|
|
7
|
1
|
|
|
1
|
|
11
|
use vars qw(@ISA @EXPORT $VERSION); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
1244
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@ISA = qw(Exporter AutoLoader); |
|
10
|
|
|
|
|
|
|
@EXPORT = qw(&VarPrint &VarPrintAsString); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = "1.01"; # $Date: 2002/08/15 2:08:15 $ |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub VarPrint { |
|
15
|
0
|
|
|
0
|
0
|
|
print _VarPrintAsString(@_, ""), "\n"; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub VarPrintAsString { |
|
19
|
0
|
|
|
0
|
0
|
|
return _VarPrintAsString(@_, "")."\n"; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _SimpleVarPrintAsString { |
|
23
|
0
|
|
|
0
|
|
|
my $var = shift; |
|
24
|
0
|
0
|
0
|
|
|
|
my $quot = (($var =~ /^[0-9]*(\.[0-9]*)?$/) && !($var =~ /^\.?$/) ? "" : "'"); |
|
25
|
0
|
|
|
|
|
|
return $quot.$var.$quot; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _VarPrintAsString { |
|
29
|
0
|
|
|
0
|
|
|
my $result = ""; |
|
30
|
0
|
|
|
|
|
|
my $spaces = pop; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# return _VarPrintAsString(\@_, $spaces) if @_ > 1; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $value = shift; |
|
35
|
0
|
0
|
|
|
|
|
unless (defined $value) { |
|
36
|
0
|
|
|
|
|
|
return "undef"; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
0
|
0
|
|
|
|
if (@_ > 1 || ref($value) eq "ARRAY") { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if (@_ > 1) { |
|
41
|
0
|
|
|
|
|
|
$result .= "("; |
|
42
|
0
|
|
|
|
|
|
$value = \@_; |
|
43
|
|
|
|
|
|
|
} else { |
|
44
|
0
|
|
|
|
|
|
$result .= "["; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
0
|
|
|
|
|
|
my $separator = ""; |
|
47
|
0
|
|
|
|
|
|
my $nl = ((grep { ref($_) =~ /^(HASH|ARRAY)$/ } @$value) == 0); |
|
|
0
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
unless ($nl) { |
|
49
|
0
|
|
|
|
|
|
$spaces .= " "; |
|
50
|
0
|
|
|
|
|
|
$result .= "\n$spaces" |
|
51
|
|
|
|
|
|
|
}; |
|
52
|
0
|
|
|
|
|
|
foreach my $item (@$value) { |
|
53
|
0
|
|
|
|
|
|
$result .= $separator._VarPrintAsString($item, $spaces); |
|
54
|
0
|
0
|
|
|
|
|
$separator = ",".($nl ? " " : "\n$spaces"); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
0
|
|
|
|
|
|
$spaces =~ s/ (.*)$/$1/; |
|
57
|
0
|
0
|
|
|
|
|
$result .= "\n$spaces" unless $nl; |
|
58
|
0
|
0
|
|
|
|
|
$result .= (@_ > 1 ? ")" : "]"); |
|
59
|
|
|
|
|
|
|
} elsif (ref($value) eq "HASH") { |
|
60
|
0
|
0
|
|
|
|
|
if (keys %$value > 0) { |
|
61
|
0
|
|
|
|
|
|
$result .= "{\n"; |
|
62
|
0
|
|
|
|
|
|
my $separator = ""; |
|
63
|
0
|
|
|
|
|
|
foreach my $key (sort keys %$value) { |
|
64
|
0
|
|
|
|
|
|
$result .= $separator.$spaces." "._SimpleVarPrintAsString($key)." => "._VarPrintAsString($value->{$key}, "$spaces "); |
|
65
|
0
|
|
|
|
|
|
$separator = ",\n"; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
0
|
|
|
|
|
|
$result .= "\n$spaces}"; |
|
68
|
|
|
|
|
|
|
} else { |
|
69
|
0
|
|
|
|
|
|
$result .= "{}"; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} elsif (ref($value) eq "") { |
|
72
|
0
|
|
|
|
|
|
$result .= _SimpleVarPrintAsString($value); |
|
73
|
|
|
|
|
|
|
} elsif (ref($value) eq "SCALAR") { |
|
74
|
0
|
|
|
|
|
|
$result .= '\\'._SimpleVarPrintAsString($$value); |
|
75
|
|
|
|
|
|
|
} elsif (ref($value) eq "CODE") { |
|
76
|
0
|
|
|
|
|
|
$result .= "Subroutine"; |
|
77
|
|
|
|
|
|
|
} else { |
|
78
|
0
|
|
|
|
|
|
$result .= "Object of class ".ref($value); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
0
|
|
|
|
|
|
return $result; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |