Update: The Config::General->save_file method calls the _store method, which in turn traverses the hash with a keys method on line 1252.

And thereabout is where the problem lies. The module takes extra care of preserving ties on the data (thus on the order, if tied to Tie::IxHash), up to calling this method, store_. And there, it foolishly throws it away:

sub _store { # # internal sub for saving a block # my($this, $level, %config) = @_; ... }
Ouch.

This assignment of the sorted hash data to an ordinary hash %config is where the semi-random order comes from — only to traverse it later on.

Tieing to any hash is useless this way.

I'd call that a bug. I think it'd be better if _store accepted a hashref instead of flat data, to traverse the data tree.


In reply to Re^2: Retaining hash order with Config::General? by bart
in thread Retaining hash order with Config::General? by Anonymous Monk

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.