line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::Syck; |
2
|
14
|
|
|
14
|
|
6813
|
use strict; |
|
14
|
|
|
|
|
22
|
|
|
14
|
|
|
|
|
594
|
|
3
|
14
|
|
|
14
|
|
62
|
use vars qw( $VERSION @EXPORT_OK @ISA ); |
|
14
|
|
|
|
|
21
|
|
|
14
|
|
|
|
|
811
|
|
4
|
14
|
|
|
14
|
|
64
|
use Exporter; |
|
14
|
|
|
|
|
21
|
|
|
14
|
|
|
|
|
473
|
|
5
|
14
|
|
|
14
|
|
1742
|
use YAML::Syck (); |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
873
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
14
|
|
|
14
|
|
31
|
$VERSION = '1.29_01'; |
9
|
14
|
|
|
|
|
37
|
@EXPORT_OK = qw( Load Dump LoadFile DumpFile DumpInto ); |
10
|
14
|
|
|
|
|
121
|
@ISA = 'Exporter'; |
11
|
14
|
|
|
|
|
41
|
*Load = \&YAML::Syck::LoadJSON; |
12
|
14
|
|
|
|
|
5010
|
*Dump = \&YAML::Syck::DumpJSON; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub DumpFile { |
16
|
0
|
|
|
0
|
0
|
0
|
my $file = shift; |
17
|
0
|
0
|
|
|
|
0
|
if ( YAML::Syck::_is_glob($file) ) { |
18
|
0
|
|
|
|
|
0
|
my $err = YAML::Syck::DumpJSONFile( $_[0], $file ); |
19
|
0
|
0
|
|
|
|
0
|
if ($err) { |
20
|
0
|
|
|
|
|
0
|
$! = 0 + $err; |
21
|
0
|
|
|
|
|
0
|
die "Error writing to filehandle $file: $!\n"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
0
|
0
|
|
|
|
0
|
open( my $fh, '>', $file ) or die "Cannot write to $file: $!"; |
26
|
0
|
|
|
|
|
0
|
my $err = YAML::Syck::DumpJSONFile( $_[0], $fh ); |
27
|
0
|
0
|
|
|
|
0
|
if ($err) { |
28
|
0
|
|
|
|
|
0
|
$! = 0 + $err; |
29
|
0
|
|
|
|
|
0
|
die "Error writing to file $file: $!\n"; |
30
|
|
|
|
|
|
|
} |
31
|
0
|
0
|
|
|
|
0
|
close $fh |
32
|
|
|
|
|
|
|
or die "Error writing to file $file: $!\n"; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
0
|
return 1; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub LoadFile { |
38
|
10
|
|
|
10
|
0
|
7670
|
my $file = shift; |
39
|
10
|
100
|
|
|
|
34
|
if ( YAML::Syck::_is_glob($file) ) { |
40
|
|
|
|
|
|
|
YAML::Syck::LoadJSON( |
41
|
8
|
|
|
|
|
6
|
do { local $/; <$file> } |
|
8
|
|
|
|
|
27
|
|
|
8
|
|
|
|
|
432
|
|
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
2
|
100
|
66
|
|
|
46
|
if ( !-e $file || -z $file ) { |
46
|
1
|
|
|
|
|
12
|
die("'$file' is non-existent or empty"); |
47
|
|
|
|
|
|
|
} |
48
|
1
|
50
|
|
|
|
21
|
open( my $fh, '<', $file ) or die "Cannot read from $file: $!"; |
49
|
|
|
|
|
|
|
YAML::Syck::LoadJSON( |
50
|
1
|
|
|
|
|
1
|
do { local $/; <$fh> } |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
55
|
|
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub DumpInto { |
56
|
7
|
|
|
7
|
0
|
44
|
my $bufref = shift; |
57
|
7
|
50
|
|
|
|
14
|
( ref $bufref ) or die "DumpInto not given reference to output buffer\n"; |
58
|
7
|
|
|
|
|
249
|
YAML::Syck::DumpJSONInto( $_[0], $bufref ); |
59
|
7
|
|
|
|
|
16
|
1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$JSON::Syck::ImplicitTyping = 1; |
63
|
|
|
|
|
|
|
$JSON::Syck::MaxDepth = 512; |
64
|
|
|
|
|
|
|
$JSON::Syck::Headless = 1; |
65
|
|
|
|
|
|
|
$JSON::Syck::ImplicitUnicode = 0; |
66
|
|
|
|
|
|
|
$JSON::Syck::SingleQuote = 0; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |