Hello Monks, So I earlier posted a similar unclear question to which I was not able to understand the answer.

I have a STANDARD.XML and I have separated them into two XML files because as a single file, they were inconsistent with the data that I'm trying to parse. Let's say they are TOP.XML and LOWER.XML. Now I'm trying to stores these files in an array and compare them.How can one store the entire file in an array?

By separating the XML files I have tried to fetch the attributes values separately from each of the XML files and write them to a single output file, Now I have to compare the two XML files and declare, (i.e.) Hint:"foreach of the LOWER.XML data, if the data "NOT" present in TOP.XML, then it can be declared as the output or written into that single file"

Does it mean I have to again create another file and write them into that and move it back to original file, if that's how it's written, how to move them to a original file?

My snippet would look something like the below

foreach (<TMP1>) { my $tmp_1 = $_; chomp ($tmp_1); print LOG $gen; foreach (<TMP2>) { my $tmp_2 = $_; chomp($tmp_2); if($tmp_1 ne $tmp_2) { print "wire"; } } }

I'm using XML::Simple part, though he's not the right one, currently I have gone almost the whole way with it, just a little bit more!

Thanks!


In reply to Comparing two XML files with XML::Simple using FOREACH and IF using by gr.d

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.