in reply to Re: Finding the parent of a text in a file ( is_deeply )
in thread Finding the parent of a text in a file

Thanks lnickt for your help.
This program indeed does work But the issue is I have 2 very huge files to compare and they can have any hierarchy apart from system/security/entry etc (thus I cannot hard code the keys/key-value in the program).
Also, In this case the difference was in the child of entry 1, similarly in my file the difference can be at the entry 229 (say) , then it would become hard for me to go back till parent and print the same.

  • Comment on Re^2: Finding the parent of a text in a file ( is_deeply )

Replies are listed 'Best First'.
Re^3: Finding the parent of a text in a file ( is_deeply )
by 1nickt (Canon) on Sep 04, 2015 at 15:40 UTC

    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.

      Thanks 1nickt for your inputs.I have got lot to learn.
      You are right...I tried Choroba's solution and it worked nicely.Thanks again.