920 lines
23 KiB
HTML
920 lines
23 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of YAML::Tiny</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>YAML::Tiny</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2018-03-10<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
YAML::Tiny - Read/Write YAML files with as little code as possible
|
|
<A NAME="lbAC"> </A>
|
|
<H2>VERSION</H2>
|
|
|
|
|
|
|
|
version 1.73
|
|
<A NAME="lbAD"> </A>
|
|
<H2>PREAMBLE</H2>
|
|
|
|
|
|
|
|
The <FONT SIZE="-1">YAML</FONT> specification is huge. Really, <B>really</B> huge. It contains all the
|
|
functionality of <FONT SIZE="-1">XML,</FONT> except with flexibility and choice, which makes it
|
|
easier to read, but with a formal specification that is more complex than
|
|
<FONT SIZE="-1">XML.</FONT>
|
|
<P>
|
|
|
|
The original pure-Perl implementation <FONT SIZE="-1">YAML</FONT> costs just over 4 megabytes
|
|
of memory to load. Just like with Windows <I>.ini</I> files (3 meg to load) and
|
|
<FONT SIZE="-1">CSS</FONT> (3.5 meg to load) the situation is just asking for a <B>YAML::Tiny</B>
|
|
module, an incomplete but correct and usable subset of the functionality,
|
|
in as little code as possible.
|
|
<P>
|
|
|
|
Like the other <TT>"::Tiny"</TT> modules, YAML::Tiny has no non-core dependencies,
|
|
does not require a compiler to install, is back-compatible to Perl v5.8.1,
|
|
and can be inlined into other modules if needed.
|
|
<P>
|
|
|
|
In exchange for this adding this extreme flexibility, it provides support
|
|
for only a limited subset of <FONT SIZE="-1">YAML.</FONT> But the subset supported contains most
|
|
of the features for the more common uses of <FONT SIZE="-1">YAML.</FONT>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
Assuming <I>file.yml</I> like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
---
|
|
rootproperty: blah
|
|
section:
|
|
one: two
|
|
three: four
|
|
Foo: Bar
|
|
empty: ~
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Read and write <I>file.yml</I> like this:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
use YAML::Tiny;
|
|
|
|
# Open the config
|
|
my $yaml = YAML::Tiny->read( 'file.yml' );
|
|
|
|
# Get a reference to the first document
|
|
my $config = $yaml->[0];
|
|
|
|
# Or read properties directly
|
|
my $root = $yaml->[0]->{rootproperty};
|
|
my $one = $yaml->[0]->{section}->{one};
|
|
my $Foo = $yaml->[0]->{section}->{Foo};
|
|
|
|
# Change data directly
|
|
$yaml->[0]->{newsection} = { this => 'that' }; # Add a section
|
|
$yaml->[0]->{section}->{Foo} = 'Not Bar!'; # Change a value
|
|
delete $yaml->[0]->{section}; # Delete a value
|
|
|
|
# Save the document back to the file
|
|
$yaml->write( 'file.yml' );
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
To create a new <FONT SIZE="-1">YAML</FONT> file from scratch:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
# Create a new object with a single hashref document
|
|
my $yaml = YAML::Tiny->new( { wibble => "wobble" } );
|
|
|
|
# Add an arrayref document
|
|
push @$yaml, [ 'foo', 'bar', 'baz' ];
|
|
|
|
# Save both documents to a file
|
|
$yaml->write( 'data.yml' );
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Then <I>data.yml</I> will contain:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
---
|
|
wibble: wobble
|
|
---
|
|
- foo
|
|
- bar
|
|
- baz
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
<B>YAML::Tiny</B> is a perl class for reading and writing YAML-style files,
|
|
written with as little code as possible, reducing load time and memory
|
|
overhead.
|
|
<P>
|
|
|
|
Most of the time it is accepted that Perl applications use a lot
|
|
of memory and modules. The <B>::Tiny</B> family of modules is specifically
|
|
intended to provide an ultralight and zero-dependency alternative to
|
|
many more-thorough standard modules.
|
|
<P>
|
|
|
|
This module is primarily for reading human-written files (like simple
|
|
config files) and generating very simple human-readable files. Note that
|
|
I said <B>human-readable</B> and not <B>geek-readable</B>. The sort of files that
|
|
your average manager or secretary should be able to look at and make
|
|
sense of.
|
|
<P>
|
|
|
|
YAML::Tiny does not generate comments, it won't necessarily preserve the
|
|
order of your hashes, and it will normalise if reading in and writing out
|
|
again.
|
|
<P>
|
|
|
|
It only supports a very basic subset of the full <FONT SIZE="-1">YAML</FONT> specification.
|
|
<P>
|
|
|
|
Usage is targeted at files like Perl's <FONT SIZE="-1">META</FONT>.yml, for which a small and
|
|
easily-embeddable module is extremely attractive.
|
|
<P>
|
|
|
|
Features will only be added if they are human readable, and can be written
|
|
in a few lines of code. Please don't be offended if your request is
|
|
refused. Someone has to draw the line, and for YAML::Tiny that someone
|
|
is me.
|
|
<P>
|
|
|
|
If you need something with more power move up to <FONT SIZE="-1">YAML</FONT> (7 megabytes of
|
|
memory overhead) or <FONT SIZE="-1">YAML::XS</FONT> (6 megabytes memory overhead and requires
|
|
a C compiler).
|
|
<P>
|
|
|
|
To restate, YAML::Tiny does <B>not</B> preserve your comments, whitespace,
|
|
or the order of your <FONT SIZE="-1">YAML</FONT> data. But it should round-trip from Perl
|
|
structure to file and back again just fine.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H3>new</H3>
|
|
|
|
|
|
|
|
The constructor <TT>"new"</TT> creates a <TT>"YAML::Tiny"</TT> object as a blessed array
|
|
reference. Any arguments provided are taken as separate documents
|
|
to be serialized.
|
|
<A NAME="lbAI"> </A>
|
|
<H3>read $filename</H3>
|
|
|
|
|
|
|
|
|
|
|
|
The <TT>"read"</TT> constructor reads a <FONT SIZE="-1">YAML</FONT> file from a file name,
|
|
and returns a new <TT>"YAML::Tiny"</TT> object containing the parsed content.
|
|
<P>
|
|
|
|
Returns the object on success or throws an error on failure.
|
|
<A NAME="lbAJ"> </A>
|
|
<H3>read_string $string;</H3>
|
|
|
|
|
|
|
|
|
|
|
|
The <TT>"read_string"</TT> constructor reads <FONT SIZE="-1">YAML</FONT> data from a character string, and
|
|
returns a new <TT>"YAML::Tiny"</TT> object containing the parsed content. If you have
|
|
read the string from a file yourself, be sure that you have correctly decoded
|
|
it into characters first.
|
|
<P>
|
|
|
|
Returns the object on success or throws an error on failure.
|
|
<A NAME="lbAK"> </A>
|
|
<H3>write $filename</H3>
|
|
|
|
|
|
|
|
|
|
|
|
The <TT>"write"</TT> method generates the file content for the properties, and
|
|
writes it to disk using <FONT SIZE="-1">UTF-8</FONT> encoding to the filename specified.
|
|
<P>
|
|
|
|
Returns true on success or throws an error on failure.
|
|
<A NAME="lbAL"> </A>
|
|
<H3>write_string</H3>
|
|
|
|
|
|
|
|
Generates the file content for the object and returns it as a character
|
|
string. This may contain non-ASCII characters and should be encoded
|
|
before writing it to a file.
|
|
<P>
|
|
|
|
Returns true on success or throws an error on failure.
|
|
<A NAME="lbAM"> </A>
|
|
<H3>errstr (<FONT SIZE="-1">DEPRECATED</FONT>)</H3>
|
|
|
|
|
|
|
|
Prior to version 1.57, some errors were fatal and others were available only
|
|
via the <TT>$YAML::Tiny::errstr</TT> variable, which could be accessed via the
|
|
<TT>"errstr()"</TT> method.
|
|
<P>
|
|
|
|
Starting with version 1.57, all errors are fatal and throw exceptions.
|
|
<P>
|
|
|
|
The <TT>$errstr</TT> variable is still set when exceptions are thrown, but
|
|
<TT>$errstr</TT> and the <TT>"errstr()"</TT> method are deprecated and may be removed in a
|
|
future release. The first use of <TT>"errstr()"</TT> will issue a deprecation
|
|
warning.
|
|
<A NAME="lbAN"> </A>
|
|
<H2>FUNCTIONS</H2>
|
|
|
|
|
|
|
|
YAML::Tiny implements a number of functions to add compatibility with
|
|
the <FONT SIZE="-1">YAML</FONT> <FONT SIZE="-1">API.</FONT> These should be a drop-in replacement.
|
|
<A NAME="lbAO"> </A>
|
|
<H3>Dump</H3>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $string = Dump(list-of-Perl-data-structures);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Turn Perl data into <FONT SIZE="-1">YAML.</FONT> This function works very much like
|
|
<I>Data::Dumper::Dumper()</I>.
|
|
<P>
|
|
|
|
It takes a list of Perl data structures and dumps them into a serialized
|
|
form.
|
|
<P>
|
|
|
|
It returns a character string containing the <FONT SIZE="-1">YAML</FONT> stream. Be sure to encode
|
|
it as <FONT SIZE="-1">UTF-8</FONT> before serializing to a file or socket.
|
|
<P>
|
|
|
|
The structures can be references or plain scalars.
|
|
<P>
|
|
|
|
Dies on any error.
|
|
<A NAME="lbAP"> </A>
|
|
<H3>Load</H3>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my @data_structures = Load(string-containing-a-YAML-stream);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Turn <FONT SIZE="-1">YAML</FONT> into Perl data. This is the opposite of Dump.
|
|
<P>
|
|
|
|
Just like Storable's <I>thaw()</I> function or the <I>eval()</I> function in relation
|
|
to Data::Dumper.
|
|
<P>
|
|
|
|
It parses a character string containing a valid <FONT SIZE="-1">YAML</FONT> stream into a list of
|
|
Perl data structures representing the individual <FONT SIZE="-1">YAML</FONT> documents. Be sure to
|
|
decode the character string correctly if the string came from a file or
|
|
socket.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
my $last_data_structure = Load(string-containing-a-YAML-stream);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
For consistency with <FONT SIZE="-1">YAML</FONT>.pm, when Load is called in scalar context, it
|
|
returns the data structure corresponding to the last of the <FONT SIZE="-1">YAML</FONT> documents
|
|
found in the input stream.
|
|
<P>
|
|
|
|
Dies on any error.
|
|
<A NAME="lbAQ"> </A>
|
|
<H3><I>freeze()</I> and <I>thaw()</I></H3>
|
|
|
|
|
|
|
|
Aliases to <I>Dump()</I> and <I>Load()</I> for Storable fans. This will also allow
|
|
YAML::Tiny to be plugged directly into modules like <FONT SIZE="-1">POE</FONT>.pm, that use the
|
|
freeze/thaw <FONT SIZE="-1">API</FONT> for internal serialization.
|
|
<A NAME="lbAR"> </A>
|
|
<H3>DumpFile(filepath, list)</H3>
|
|
|
|
|
|
|
|
Writes the <FONT SIZE="-1">YAML</FONT> stream to a file with <FONT SIZE="-1">UTF-8</FONT> encoding instead of just
|
|
returning a string.
|
|
<P>
|
|
|
|
Dies on any error.
|
|
<A NAME="lbAS"> </A>
|
|
<H3>LoadFile(filepath)</H3>
|
|
|
|
|
|
|
|
Reads the <FONT SIZE="-1">YAML</FONT> stream from a <FONT SIZE="-1">UTF-8</FONT> encoded file instead of a string.
|
|
<P>
|
|
|
|
Dies on any error.
|
|
<A NAME="lbAT"> </A>
|
|
<H2>YAML TINY SPECIFICATION</H2>
|
|
|
|
|
|
|
|
This section of the documentation provides a specification for ``<FONT SIZE="-1">YAML</FONT> Tiny'',
|
|
a subset of the <FONT SIZE="-1">YAML</FONT> specification.
|
|
<P>
|
|
|
|
It is based on and described comparatively to the <FONT SIZE="-1">YAML 1.1</FONT> Working Draft
|
|
2004-12-28 specification, located at <<A HREF="http://yaml.org/spec/current.html">http://yaml.org/spec/current.html</A>>.
|
|
<P>
|
|
|
|
Terminology and chapter numbers are based on that specification.
|
|
<A NAME="lbAU"> </A>
|
|
<H3>1. Introduction and Goals</H3>
|
|
|
|
|
|
|
|
The purpose of the <FONT SIZE="-1">YAML</FONT> Tiny specification is to describe a useful subset
|
|
of the <FONT SIZE="-1">YAML</FONT> specification that can be used for typical document-oriented
|
|
use cases such as configuration files and simple data structure dumps.
|
|
<P>
|
|
|
|
Many specification elements that add flexibility or extensibility are
|
|
intentionally removed, as is support for complex data structures, class
|
|
and object-orientation.
|
|
<P>
|
|
|
|
In general, the <FONT SIZE="-1">YAML</FONT> Tiny language targets only those data structures
|
|
available in <FONT SIZE="-1">JSON,</FONT> with the additional limitation that only simple keys
|
|
are supported.
|
|
<P>
|
|
|
|
As a result, all possible <FONT SIZE="-1">YAML</FONT> Tiny documents should be able to be
|
|
transformed into an equivalent <FONT SIZE="-1">JSON</FONT> document, although the reverse is
|
|
not necessarily true (but will be true in simple cases).
|
|
<P>
|
|
|
|
As a result of these simplifications the <FONT SIZE="-1">YAML</FONT> Tiny specification should
|
|
be implementable in a (relatively) small amount of code in any language
|
|
that supports Perl Compatible Regular Expressions (<FONT SIZE="-1">PCRE</FONT>).
|
|
<A NAME="lbAV"> </A>
|
|
<H3>2. Introduction</H3>
|
|
|
|
|
|
|
|
<FONT SIZE="-1">YAML</FONT> Tiny supports three data structures. These are scalars (in a variety
|
|
of forms), block-form sequences and block-form mappings. Flow-style
|
|
sequences and mappings are not supported, with some minor exceptions
|
|
detailed later.
|
|
<P>
|
|
|
|
The use of three dashes ``---'' to indicate the start of a new document is
|
|
supported, and multiple documents per file/stream is allowed.
|
|
<P>
|
|
|
|
Both line and inline comments are supported.
|
|
<P>
|
|
|
|
Scalars are supported via the plain style, single quote and double quote,
|
|
as well as literal-style and folded-style multi-line scalars.
|
|
<P>
|
|
|
|
The use of explicit tags is not supported.
|
|
<P>
|
|
|
|
The use of ``null'' type scalars is supported via the ~ character.
|
|
<P>
|
|
|
|
The use of ``bool'' type scalars is not supported.
|
|
<P>
|
|
|
|
However, serializer implementations should take care to explicitly escape
|
|
strings that match a ``bool'' keyword in the following set to prevent other
|
|
implementations that do support ``bool'' accidentally reading a string as a
|
|
boolean
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
y|Y|yes|Yes|YES|n|N|no|No|NO
|
|
|true|True|TRUE|false|False|FALSE
|
|
|on|On|ON|off|Off|OFF
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
The use of anchors and aliases is not supported.
|
|
<P>
|
|
|
|
The use of directives is supported only for the <TT>%YAML</TT> directive.
|
|
<A NAME="lbAW"> </A>
|
|
<H3>3. Processing <FONT SIZE="-1">YAML</FONT> Tiny Information</H3>
|
|
|
|
|
|
|
|
<B>Processes</B>
|
|
<P>
|
|
|
|
The <FONT SIZE="-1">YAML</FONT> specification dictates three-phase serialization and three-phase
|
|
deserialization.
|
|
<P>
|
|
|
|
The <FONT SIZE="-1">YAML</FONT> Tiny specification does not mandate any particular methodology
|
|
or mechanism for parsing.
|
|
<P>
|
|
|
|
Any compliant parser is only required to parse a single document at a
|
|
time. The ability to support streaming documents is optional and most
|
|
likely non-typical.
|
|
<P>
|
|
|
|
Because anchors and aliases are not supported, the resulting representation
|
|
graph is thus directed but (unlike the main <FONT SIZE="-1">YAML</FONT> specification) <B>acyclic</B>.
|
|
<P>
|
|
|
|
Circular references/pointers are not possible, and any <FONT SIZE="-1">YAML</FONT> Tiny serializer
|
|
detecting a circular reference should error with an appropriate message.
|
|
<P>
|
|
|
|
<B>Presentation Stream</B>
|
|
<P>
|
|
|
|
<FONT SIZE="-1">YAML</FONT> Tiny reads and write <FONT SIZE="-1">UTF-8</FONT> encoded files. Operations on strings expect
|
|
or produce Unicode characters not <FONT SIZE="-1">UTF-8</FONT> encoded bytes.
|
|
<P>
|
|
|
|
<B>Loading Failure Points</B>
|
|
<P>
|
|
|
|
<FONT SIZE="-1">YAML</FONT> Tiny parsers and emitters are not expected to recover from, or
|
|
adapt to, errors. The specific error modality of any implementation is
|
|
not dictated (return codes, exceptions, etc.) but is expected to be
|
|
consistent.
|
|
<A NAME="lbAX"> </A>
|
|
<H3>4. Syntax</H3>
|
|
|
|
|
|
|
|
<B>Character Set</B>
|
|
<P>
|
|
|
|
<FONT SIZE="-1">YAML</FONT> Tiny streams are processed in memory as Unicode characters and
|
|
read/written with <FONT SIZE="-1">UTF-8</FONT> encoding.
|
|
<P>
|
|
|
|
The escaping and unescaping of the 8-bit <FONT SIZE="-1">YAML</FONT> escapes is required.
|
|
<P>
|
|
|
|
The escaping and unescaping of 16-bit and 32-bit <FONT SIZE="-1">YAML</FONT> escapes is not
|
|
required.
|
|
<P>
|
|
|
|
<B>Indicator Characters</B>
|
|
<P>
|
|
|
|
Support for the ``~'' null/undefined indicator is required.
|
|
<P>
|
|
|
|
Implementations may represent this as appropriate for the underlying
|
|
language.
|
|
<P>
|
|
|
|
Support for the ``-'' block sequence indicator is required.
|
|
<P>
|
|
|
|
Support for the ``?'' mapping key indicator is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for the ``:'' mapping value indicator is required.
|
|
<P>
|
|
|
|
Support for the ``,'' flow collection indicator is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for the ``['' flow sequence indicator is <B>not</B> required, with
|
|
one exception (detailed below).
|
|
<P>
|
|
|
|
Support for the ``]'' flow sequence indicator is <B>not</B> required, with
|
|
one exception (detailed below).
|
|
<P>
|
|
|
|
Support for the ``{'' flow mapping indicator is <B>not</B> required, with
|
|
one exception (detailed below).
|
|
<P>
|
|
|
|
Support for the ``}'' flow mapping indicator is <B>not</B> required, with
|
|
one exception (detailed below).
|
|
<P>
|
|
|
|
Support for the ``#'' comment indicator is required.
|
|
<P>
|
|
|
|
Support for the ``&'' anchor indicator is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for the ``*'' alias indicator is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for the ``!'' tag indicator is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for the ``|'' literal block indicator is required.
|
|
<P>
|
|
|
|
Support for the ``>'' folded block indicator is required.
|
|
<P>
|
|
|
|
Support for the ``''' single quote indicator is required.
|
|
<P>
|
|
|
|
Support for the """ double quote indicator is required.
|
|
<P>
|
|
|
|
Support for the ``%'' directive indicator is required, but only
|
|
for the special case of a <TT>%YAML</TT> version directive before the
|
|
``---'' document header, or on the same line as the document header.
|
|
<P>
|
|
|
|
For example:
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
%YAML 1.1
|
|
---
|
|
- A sequence with a single element
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Special Exception:
|
|
<P>
|
|
|
|
To provide the ability to support empty sequences
|
|
and mappings, support for the constructs [] (empty sequence) and {}
|
|
(empty mapping) are required.
|
|
<P>
|
|
|
|
For example,
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
%YAML 1.1
|
|
# A document consisting of only an empty mapping
|
|
--- {}
|
|
# A document consisting of only an empty sequence
|
|
--- []
|
|
# A document consisting of an empty mapping within a sequence
|
|
- foo
|
|
- {}
|
|
- bar
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
<B>Syntax Primitives</B>
|
|
<P>
|
|
|
|
Other than the empty sequence and mapping cases described above, <FONT SIZE="-1">YAML</FONT> Tiny
|
|
supports only the indentation-based block-style group of contexts.
|
|
<P>
|
|
|
|
All five scalar contexts are supported.
|
|
<P>
|
|
|
|
Indentation spaces work as per the <FONT SIZE="-1">YAML</FONT> specification in all cases.
|
|
<P>
|
|
|
|
Comments work as per the <FONT SIZE="-1">YAML</FONT> specification in all simple cases.
|
|
Support for indented multi-line comments is <B>not</B> required.
|
|
<P>
|
|
|
|
Separation spaces work as per the <FONT SIZE="-1">YAML</FONT> specification in all cases.
|
|
<P>
|
|
|
|
<B></B><FONT SIZE="-1"><B>YAML</B></FONT><B> Tiny Character Stream</B>
|
|
<P>
|
|
|
|
The only directive supported by the <FONT SIZE="-1">YAML</FONT> Tiny specification is the
|
|
<TT>%YAML</TT> language/version identifier. Although detected, this directive
|
|
will have no control over the parsing itself.
|
|
<P>
|
|
|
|
The parser must recognise both the <FONT SIZE="-1">YAML 1.0</FONT> and <FONT SIZE="-1">YAML 1.1+</FONT> formatting
|
|
of this directive (as well as the commented form, although no explicit
|
|
code should be needed to deal with this case, being a comment anyway)
|
|
<P>
|
|
|
|
That is, all of the following should be supported.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
--- #YAML:1.0
|
|
- foo
|
|
|
|
%YAML:1.0
|
|
---
|
|
- foo
|
|
|
|
% YAML 1.1
|
|
---
|
|
- foo
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
Support for the <TT>%TAG</TT> directive is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for additional directives is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for the document boundary marker ``---'' is required.
|
|
<P>
|
|
|
|
Support for the document boundary market ``...'' is <B>not</B> required.
|
|
<P>
|
|
|
|
If necessary, a document boundary should simply by indicated with a
|
|
``---'' marker, with not preceding ``...'' marker.
|
|
<P>
|
|
|
|
Support for empty streams (containing no documents) is required.
|
|
<P>
|
|
|
|
Support for implicit document starts is required.
|
|
<P>
|
|
|
|
That is, the following must be equivalent.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
# Full form
|
|
%YAML 1.1
|
|
---
|
|
foo: bar
|
|
|
|
# Implicit form
|
|
foo: bar
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
<B>Nodes</B>
|
|
<P>
|
|
|
|
Support for nodes optional anchor and tag properties is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for node anchors is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for node tags is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for alias nodes is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for flow nodes is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for block nodes is required.
|
|
<P>
|
|
|
|
<B>Scalar Styles</B>
|
|
<P>
|
|
|
|
Support for all five scalar styles is required as per the <FONT SIZE="-1">YAML</FONT>
|
|
specification, although support for quoted scalars spanning more
|
|
than one line is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for multi-line scalar documents starting on the header
|
|
is not required.
|
|
<P>
|
|
|
|
Support for the chomping indicators on multi-line scalar styles
|
|
is required.
|
|
<P>
|
|
|
|
<B>Collection Styles</B>
|
|
<P>
|
|
|
|
Support for block-style sequences is required.
|
|
<P>
|
|
|
|
Support for flow-style sequences is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for block-style mappings is required.
|
|
<P>
|
|
|
|
Support for flow-style mappings is <B>not</B> required.
|
|
<P>
|
|
|
|
Both sequences and mappings should be able to be arbitrarily
|
|
nested.
|
|
<P>
|
|
|
|
Support for plain-style mapping keys is required.
|
|
<P>
|
|
|
|
Support for quoted keys in mappings is <B>not</B> required.
|
|
<P>
|
|
|
|
Support for ``?''-indicated explicit keys is <B>not</B> required.
|
|
<P>
|
|
|
|
Here endeth the specification.
|
|
<A NAME="lbAY"> </A>
|
|
<H3>Additional Perl-Specific Notes</H3>
|
|
|
|
|
|
|
|
For some Perl applications, it's important to know if you really have a
|
|
number and not a string.
|
|
<P>
|
|
|
|
That is, in some contexts is important that 3 the number is distinctive
|
|
from ``3'' the string.
|
|
<P>
|
|
|
|
Because even Perl itself is not trivially able to understand the difference
|
|
(certainly without XS-based modules) Perl implementations of the <FONT SIZE="-1">YAML</FONT> Tiny
|
|
specification are not required to retain the distinctiveness of 3 vs ``3''.
|
|
<A NAME="lbAZ"> </A>
|
|
<H2>SUPPORT</H2>
|
|
|
|
|
|
|
|
Bugs should be reported via the <FONT SIZE="-1">CPAN</FONT> bug tracker at
|
|
<P>
|
|
|
|
<<A HREF="http://rt.cpan.org/NoAuth/ReportBug.html?Queue=YAML-Tiny">http://rt.cpan.org/NoAuth/ReportBug.html?Queue=YAML-Tiny</A>>
|
|
<A NAME="lbBA"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Adam Kennedy <<A HREF="mailto:adamk@cpan.org">adamk@cpan.org</A>>
|
|
<A NAME="lbBB"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">•<DD>
|
|
<FONT SIZE="-1">YAML</FONT>
|
|
<DT id="2">•<DD>
|
|
YAML::Syck
|
|
<DT id="3">•<DD>
|
|
Config::Tiny
|
|
<DT id="4">•<DD>
|
|
CSS::Tiny
|
|
<DT id="5">•<DD>
|
|
<<A HREF="http://use.perl.org/use.perl.org/_Alias/journal/29427.html">http://use.perl.org/use.perl.org/_Alias/journal/29427.html</A>>
|
|
<DT id="6">•<DD>
|
|
<<A HREF="http://ali.as/">http://ali.as/</A>>
|
|
</DL>
|
|
<A NAME="lbBC"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright 2006 - 2013 Adam Kennedy.
|
|
<P>
|
|
|
|
This program is free software; you can redistribute
|
|
it and/or modify it under the same terms as Perl itself.
|
|
<P>
|
|
|
|
The full text of the license can be found in the
|
|
<FONT SIZE="-1">LICENSE</FONT> file included with this module.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="7"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="8"><A HREF="#lbAC">VERSION</A><DD>
|
|
<DT id="9"><A HREF="#lbAD">PREAMBLE</A><DD>
|
|
<DT id="10"><A HREF="#lbAE">SYNOPSIS</A><DD>
|
|
<DT id="11"><A HREF="#lbAF">DESCRIPTION</A><DD>
|
|
<DT id="12"><A HREF="#lbAG">METHODS</A><DD>
|
|
<DL>
|
|
<DT id="13"><A HREF="#lbAH">new</A><DD>
|
|
<DT id="14"><A HREF="#lbAI">read $filename</A><DD>
|
|
<DT id="15"><A HREF="#lbAJ">read_string $string;</A><DD>
|
|
<DT id="16"><A HREF="#lbAK">write $filename</A><DD>
|
|
<DT id="17"><A HREF="#lbAL">write_string</A><DD>
|
|
<DT id="18"><A HREF="#lbAM">errstr (<FONT SIZE="-1">DEPRECATED</FONT>)</A><DD>
|
|
</DL>
|
|
<DT id="19"><A HREF="#lbAN">FUNCTIONS</A><DD>
|
|
<DL>
|
|
<DT id="20"><A HREF="#lbAO">Dump</A><DD>
|
|
<DT id="21"><A HREF="#lbAP">Load</A><DD>
|
|
<DT id="22"><A HREF="#lbAQ"><I>freeze()</I> and <I>thaw()</I></A><DD>
|
|
<DT id="23"><A HREF="#lbAR">DumpFile(filepath, list)</A><DD>
|
|
<DT id="24"><A HREF="#lbAS">LoadFile(filepath)</A><DD>
|
|
</DL>
|
|
<DT id="25"><A HREF="#lbAT">YAML TINY SPECIFICATION</A><DD>
|
|
<DL>
|
|
<DT id="26"><A HREF="#lbAU">1. Introduction and Goals</A><DD>
|
|
<DT id="27"><A HREF="#lbAV">2. Introduction</A><DD>
|
|
<DT id="28"><A HREF="#lbAW">3. Processing <FONT SIZE="-1">YAML</FONT> Tiny Information</A><DD>
|
|
<DT id="29"><A HREF="#lbAX">4. Syntax</A><DD>
|
|
<DT id="30"><A HREF="#lbAY">Additional Perl-Specific Notes</A><DD>
|
|
</DL>
|
|
<DT id="31"><A HREF="#lbAZ">SUPPORT</A><DD>
|
|
<DT id="32"><A HREF="#lbBA">AUTHOR</A><DD>
|
|
<DT id="33"><A HREF="#lbBB">SEE ALSO</A><DD>
|
|
<DT id="34"><A HREF="#lbBC">COPYRIGHT</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:01 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|