When I upgraded from 1.28 to 1.32 (and then 1.40), existing logic broke.
My logic was saving YAML for a hash that happened to have a key that is
an empty string. All versions of YAML::Tiny will generate identical
output, but as of 1.32 (at least), it will croak while trying to parse
the YAML it wrote.
With 1.32, the error is (see attachments for 'yt2'):
$ /usr/bin/perl yt2
$VAR1 = '---
data:
allocating:
attribute: cfg200801;pref=siteBLR
cwaiting:
SINGLEUSE&cfg200801;pref=siteBLR: 9
cfg200801;pref=siteBLR: 831
waiting:
: 831
SINGLEUSE: 9
';
Bad or unsupported hash line at /Library/Perl/Updates/5.8.8/YAML/Tiny.pm
line 268.
With 1.40, it changes to:
YAML::Tiny failed to classify line ' : 831' at yt2 line 30
The patch is very simple: move the error check for [?'"] outside of the
pattern for matching the key. See attached Tiny.pm.patch
--- Tiny.pm 2009-07-31 09:35:23.000000000 -0400
+++ Tiny.fixed.pm 2009-12-01 08:42:33.000000000 -0500
@@ -326,10 +326,10 @@
}
# Get the key
- unless ( $lines->[0] =~ s/^\s*([^\'\"
][^\n]*?)\s*:(\s+|$)// ) {
- if ( $lines->[0] =~ /^\s*[?\'\"]/ ) {
- croak("YAML::Tiny does not support a
feature in
line '$lines->[0]'");
- }
+ if ( $lines->[0] =~ /^\s*[?\'\"]/ ) {
+ croak("YAML::Tiny does not support a feature in
line '$
lines->[0]'");
+ }
+ unless ( $lines->[0] =~ s/^\s*([^\n]*?)\s*:(\s+|$)// ) {
croak("YAML::Tiny failed to classify line
'$lines->[0]'"
);
}
my $key = $1;