Subject: | Trips over "=" in hash key |
use strict;
use warnings;
use YAML;
my $hashref = {"= foo" => "bar"};
YAML::DumpFile "foo.yaml", $hashref;
my $loaded = YAML::LoadFile "foo.yaml";
__END__
Running above script gives this error:
YAML Error: Invalid element in map
Code: YAML_LOAD_ERR_BAD_MAP_ELEMENT
Line: 2
Document: 1
at C:/strawberry/perl/vendor/lib/YAML/Loader.pm line 352.
The file foo.yaml is created and looks as follows:
---
= foo: bar
Opening the file with an editor and putting quotes around the key, so
that it looks as shown below, and then trying to load it, works fine.
---
'= foo': bar
my $loaded = YAML::LoadFile "foo.yaml"; # This works, after editting file
$ perl -v
This is perl 5, version 16, subversion 1 (v5.16.1) built for
MSWin32-x64-multi-thread
...
$ perl -MYAML -e "print $YAML::VERSION"
0.84