line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::YAML; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8335
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
47
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use vars qw{$VERSION}; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
78
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.0.6'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
1; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__END__ |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Data::YAML - Easy YAML serialisation of Perl data structures |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This document describes Data::YAML version 0.0.6 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
In the spirit of L<YAML::Tiny>, L<Data::YAML::Reader> and |
25
|
|
|
|
|
|
|
L<Data::YAML::Writer> provide lightweight, dependency-free YAML |
26
|
|
|
|
|
|
|
handling. While C<YAML::Tiny> is designed principally for working with |
27
|
|
|
|
|
|
|
configuration files C<Data::YAML> concentrates on the transparent round- |
28
|
|
|
|
|
|
|
tripping of YAML serialized Perl data structures. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
As an example of why this distinction matters consider that |
31
|
|
|
|
|
|
|
C<YAML::Tiny> doesn't handle hashes with keys containing non-printable |
32
|
|
|
|
|
|
|
characters. This is fine for configuration files but likely to cause |
33
|
|
|
|
|
|
|
problems when handling arbitrary Perl data structures. C<Data::YAML> |
34
|
|
|
|
|
|
|
handles exotic hash keys correctly. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
The syntax accepted by C<Data::YAML> is a subset of YAML. Specifically |
37
|
|
|
|
|
|
|
it is the same subset of YAML that L<Data::YAML::Writer> produces. See |
38
|
|
|
|
|
|
|
L<Data::YAML> for more information. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 YAML syntax |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Although YAML appears to be a simple language the entire YAML |
43
|
|
|
|
|
|
|
specification is huge. C<Data::YAML> implements a small subset of the |
44
|
|
|
|
|
|
|
complete syntax trading completeness for compactness and simplicity. |
45
|
|
|
|
|
|
|
This restricted syntax is known (to me at least) as 'YAMLish'. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
These examples demonstrates the full range of supported syntax. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
All YAML documents must begin with '---' and end with a line |
50
|
|
|
|
|
|
|
containing '...'. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
--- Simple scalar |
53
|
|
|
|
|
|
|
... |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Unprintable characters are represented using standard escapes in double |
56
|
|
|
|
|
|
|
quoted strings. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
--- "\t\x01\x02\n" |
59
|
|
|
|
|
|
|
... |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Array and hashes are represented thusly |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
--- |
64
|
|
|
|
|
|
|
- "This" |
65
|
|
|
|
|
|
|
- "is" |
66
|
|
|
|
|
|
|
- "an" |
67
|
|
|
|
|
|
|
- "array" |
68
|
|
|
|
|
|
|
... |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
--- |
71
|
|
|
|
|
|
|
This: is |
72
|
|
|
|
|
|
|
a: hash |
73
|
|
|
|
|
|
|
... |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Structures may nest arbitrarily |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
--- |
78
|
|
|
|
|
|
|
- |
79
|
|
|
|
|
|
|
name: 'Hash one' |
80
|
|
|
|
|
|
|
value: 1 |
81
|
|
|
|
|
|
|
- |
82
|
|
|
|
|
|
|
name: 'Hash two' |
83
|
|
|
|
|
|
|
value: 2 |
84
|
|
|
|
|
|
|
... |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Undef is a tilde |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
--- ~ |
89
|
|
|
|
|
|
|
... |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 Uses |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Use C<Data::YAML> may be used any time you need to freeze and thaw Perl |
94
|
|
|
|
|
|
|
data structures into a human readable format. The output from |
95
|
|
|
|
|
|
|
C<Data::YAML::Writer> should be readable by any YAML parser. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
C<Data::YAML> was originally written to allow machine-readable |
98
|
|
|
|
|
|
|
diagnostic information to be passed from test scripts to |
99
|
|
|
|
|
|
|
L<TAP::Harness>. That means that if you're writing a testing system that |
100
|
|
|
|
|
|
|
needs to output TAP version 13 or later syntax you might find |
101
|
|
|
|
|
|
|
C<Data::YAML> useful. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Read more about TAP and YAMLish here: L<http://testanything.org/wiki> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
No bugs have been reported. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
110
|
|
|
|
|
|
|
C<data-yaml@rt.cpan.org>, or through the web interface at |
111
|
|
|
|
|
|
|
L<http://rt.cpan.org>. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Andy Armstrong C<< <andy@hexten.net> >> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Copyright (c) 2007, Andy Armstrong C<< <andy@hexten.net> >>. All rights reserved. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
122
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. See L<perlartistic>. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
127
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
128
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
129
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
130
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
131
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
132
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
133
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
134
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
137
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
138
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
139
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
140
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
141
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
142
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
143
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
144
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
145
|
|
|
|
|
|
|
SUCH DAMAGES. |