Subject: | Multiple documents are ignored when loading a YAML file |
Date: | Sun, 20 Jan 2013 17:53:44 +0100 |
To: | bug-YAML-LibYAML [...] rt.cpan.org |
From: | Jeroen De Ridder <voetsjoeba [...] gmail.com> |
YAML::XS v0.38 appears to only load the last-encountered document in a
YAML file rather than providing access to all of them.
Example YML file "test.yml":
---
documentNr: 1
...
---
documentNr: 2
...
Observe the following behaviour of YAML::XS compared to YAML::Tiny. This
is running Perl v5.8.8 on RHEL 5 x86_64.
$ perl -e 'use Data::Dumper; use YAML::Any qw/LoadFile/; my $x =
LoadFile("test.yml"); print Dumper($x);'
$VAR1 = {
'documentNr' => 2
};
$ perl -e 'use Data::Dumper; use YAML::Tiny; my $x =
YAML::Tiny->read("test.yml"); print Dumper($x);'
$VAR1 = bless( [
{
'documentNr' => '1'
},
{
'documentNr' => '2'
}
], 'YAML::Tiny');
$
There is no apparent way of getting to the first document when using
YAML::XS to parse it. I'm not familiar with libyaml, so I can't tell
whether this is due to the underlying implementation or due to any
post-processing by YAML::XS. Feel free to defer to libyaml's bug
tracking if this problem is ultimately due to libyaml.