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

Owner: Nobody in particular
Requestors: leonerd-cpan [...]

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

Subject: Loader to preserve order of mappings
Download (untitled) / with headers
text/plain 1009b
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
Download (untitled) / with headers
text/plain 247b
This issue has been copied to: 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

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to