Since you know what you're aiming at, just use the yaml as a template. Load it into Perl and then dump the resulting data structure:

use YAML::XS qw(LoadFile); use Data::Dump qw(pp); pp LoadFile(\*DATA); __DATA__ path: /export/home/frank options: - param: i value: '1001' - param f - param: x value: eyes - flag: b value: toes - param: p arguments: - value: test
Produces:
{ arguments => [{ value => "test" }], options => [ { param => "i", value => 1001 }, "param f", { param => "x", value => "eyes" }, { flag => "b", value => "toes" }, { param => "p" }, ], path => "/export/home/frank", }

Which after looking back at your original post, is essentially the same as your input (which has a missing comma). So its not a matter of finding a data structure that produces your desired YAML. Maybe it's better to have asked why you want a specific format to your YAML? Isn't any format that properly encodes your data, okay?


In reply to Re: Keeping Order with YAML::XS by Loops
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.