It seems that libyaml uses the ? ... : ... notation for long hash keys (with "long" being more than 128 characters). I think that this notation brings no readability advantage over the "normal" hash notation (in fact, this notation is quite surprising for most humans), and would vote to do a change here (this would probably be a return 1 in the YAML_SCALAR_EVENT case in yaml_emitter_check_simple_key.
After the change the following test script should pass:
#!/usr/bin/perl
use strict;
use warnings;
use YAML::XS qw(Dump);
use Test::More 'no_plan';
my $bla = '123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEFx';
is Dump({ $bla => 1 }), <<'EOF';
---
123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEFx: 1
EOF
__END__
This issue should probably be opened in https://github.com/yaml/libyaml instead, as the code you mention is in emitter.c of libyaml, and YAML::XS should usually not modify libyaml sources.
It seems that libyaml uses the
? ... : ...
notation for long hash keys (with "long" being more than 128 characters). I think that this notation brings no readability advantage over the "normal" hash notation (in fact, this notation is quite surprising for most humans), and would vote to do a change here (this would probably be areturn 1
in theYAML_SCALAR_EVENT
case inyaml_emitter_check_simple_key
.After the change the following test script should pass: