My question originates from a large software project that has a complex configuration structure.

Something similar to:

# cfg1 $config = { "common" => { debug => 1, logfile => "/var/log/project.log", path => "/opt/projects/bin", }, "project_1" => { name => "Project 1", tasks => [ { name => "Prepare", program => "p1prep", arguments => [ "--init", '--default' ], logfile => "/var/log/p1prep.log", }, { name => "Work", program => "p1", arguments => [ "--collect" ], logfile => "/var/log/p1.log", env => { DISPLAY => undef, }, }, { name => "Wrapup", program => "signal", arguments => [ "p1", "finished" ], }, ] }, "project_2" => { "and" => [ "so", "on", "..." ], }, };

A particular customer could supply her own config, e.g.

# cfg2 $config = { "common" => { debug => 0, logfile => "/var/log/project.log", path => "/opt/projects/bin", }, "project_1" => { name => "Project 1", tasks => [ { name => "Prepare", program => "p1prep", arguments => [ "--init", '--default' ], logfile => "/var/log/p1prep.log", }, { name => "Work", program => "p1", arguments => [ "--collect", "--brief" ], logfile => "/var/log/p1.log", env => { DISPLAY => undef, }, }, { name => "Wrapup", program => "signal", arguments => [ "p1", "finished" ], }, ] }, "project_2" => { "and" => [ "so", "on", "..." ], }, };

But instead of supplying a full config, it suffices to supply a smaller set of modifications:

# cfgaug $config = { "common" => { debug => 0 }, "project_1" => { tasks => [ { name => "Prepare" }, { name => "Work", arguments => [ "--collect", "--brief" ], }, { name => "Wrapup" }, ] }, };

Applying #cfgaug to #cfg1 will result in #cfg2.

Since several of these augmentations are possible, the need arises to produce a single 'delta' that augments the base configuration #cfg1 to the actual state.


In reply to Re^3: Augmenting and reducing data structures by sciurius
in thread Augmenting and reducing data structures by sciurius

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.