I can load a file without issues, and it creates what I am expecting. The issue comes when trying to dump it back. Here's an example:

in.yaml
path: /export/home/frank options: - param: i value: 1001 - param: f - param: x value: eyes arguments: - value: test
Here's the Perl code:

Perl Code
#!/usr/bin/env perl use strict; use warnings; use YAML::XS qw(LoadFile DumpFile); use Data::Dumper; my $data = LoadFile('test.yaml'); print Dumper($data); DumpFile('out.yaml', $data);
And here's the output yaml (out.yaml) that it creates:

out.yaml
--- arguments: - value: test options: - param: i value: 1001 - param: f - param: x value: eyes path: /export/home/frank
Notice that in the input file the syntax was in such a way that it was an ordered sequence (from what I am understanding of YAML anyway). Yet, in the output it is no longer ordered at all. I am trying to figure out from a Perl data structure how to make an ordered YAML file like what is the input.

In reply to Re^2: Keeping Order with YAML::XS by walkingthecow
in thread Keeping Order with YAML::XS by walkingthecow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.