```{index} single: YAML::XS::LibYAML ``` # YAML::XS::LibYAML the YAML engine behind pperl's YAML::XS ## SYNOPSIS ```perl use YAML::XS qw(Load Dump); my $data = Load("---\nname: pperl\nlist: [1, 2]\n"); print Dump($data); my $yaml = YAML::XS->new(indent => 4, footer => 1); print $yaml->dump($data); ``` ## DESCRIPTION `YAML::XS` is YAML-LibYAML 0.910.0's own module. Its compiled part, `YAML::XS::LibYAML`, which under perl wraps the libyaml C library, is this module: it reads YAML with [YAML::PP](../PP.md), pperl's YAML engine, and writes it as libyaml writes it. `Load`, `Dump`, `LoadFile`, `DumpFile`, the object interface (`new`, `load`, `dump`) and the `$YAML::XS::...` settings work as they do under perl, and `Dump` writes the same text: the same quoting, escapes, line folding and indentation. `libyaml_version` answers 0.2.4, the libyaml release whose behaviour this follows. ## DIFFERENCES FROM PERL - Error messages A document that does not parse dies with YAML::PP's account of the problem, in libyaml's layout (the problem, the document, the line and the column). The document is nearly always the one libyaml names and the line usually the same, but the words differ and the place can differ by a few columns, since the two parsers notice an error at different points. - YAML 1.2 YAML is read as the YAML 1.2 specification reads it, where libyaml, a YAML 1.1 parser, reads it otherwise: `{?foo: bar}` has the key `?foo`, `[?x]` is a list of `?x`, an anchor name may contain `:`, and `{x: :x}` or a tab after an indicator load where libyaml dies. Documents the specification rejects, which libyaml loads (`[-]`, a comment touching a quoted string), die. - LS and PS `Dump` writes the characters U+2028 and U+2029 as `\L` and `\P`. libyaml writes them unescaped, as YAML 1.1 line breaks, and a YAML 1.2 reader then loads a different string back. - Not yet read A flow collection used as a mapping key (`[flow]: block`, `{ [a]: b }`, `[ [a]: b ]`) and the key `::` do not load yet: YAML::PP does not read them, where libyaml does. - Where perl fails The object interface loads a flow mapping inside a flow sequence (`{ a: [b, { c: d }] }`), on which perl aborts, and dumps strings of latin-1 bytes, which perl refuses ("Could not initialize scalar event"). ## SEE ALSO [YAML::XS](../XS.md), [YAML::PP](../PP.md)