Hi ExperimentsWithPerl,

The data structures were only hard-coded in my example because it was an example. You would need to create the hashes on the fly from the files, and then compare them.

If you are wanting to know all the differences in the files, you could use Test::Differences::eq_or_diff_data(), but that still wouldn't print out just the hierarchy as you wish. For that, choroba's solution seems like it may be the way to go.

But any diff solution (Test::Differences, system diff, whatever) will specify the lines at which the structures differ, so if that's all you need to know it might not be necessary to make the fully qualified "paths" choroba suggested. (It would help if you provided a sample input file and an example of the actual output you'd like to see.)

The way forward always starts with a minimal test.

In reply to Re^3: Finding the parent of a text in a file ( is_deeply ) by 1nickt
in thread Finding the parent of a text in a file by ExperimentsWithPerl

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.