Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the YAML CPAN distribution.

Report information
The Basics
Id: 56741
Status: resolved
Priority: 0/
Queue: YAML

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 1.20



Subject: Loader to preserve order of mappings
Sometimes I want to load/edit/dump a YAML file, which is stored in a revision control system, such as subversion. I know that technically the order of mappings doesn't matter. However, when my YAML files are stored in a revision control system, it's nice that edits do not disturb the order more than necessary. To this end, I have applied somewhat of a horrible hack to YAML::Loader. I subclass it, copy&paste sub _parse_mapping and alter a single line: - my $mapping = {}; + my $mapping = YAML::Node->new({}); With that change, the YAML::Node representing the mapping behaves exactly like any other normal perl hash, except that the dumper dumps the keys in the right order. This lets me easily load/edit/dump YAML files without too much disturbance that upsets revision control. It would be nice if this behavior would be available as an option; perhaps $YAML::Loader::PreserveOrder = 1; I admit that in most use cases it might not be important, but here it's vital. Thanks, -- Paul Evans
This issue has been copied to: https://github.com/ingydotnet/yaml-pm/issues/106 please take all future correspondence there. This ticket will remain open but please do not reply here. This ticket will be closed when the github issue is dealt with.
Implemented as $YAML::Preserve in 1.20