Hello kalantal, and welcome to the Monastery!

It looks to me as though the author of the script relied rather too heavily on cut-and-paste. For example, in this section:

foreach $testfailure ($test->findnodes('./failure')) { $failure_type = $testfailure->getAttribute('type +'); $failure_temp = $testfailure->getAttribute('mess +age'); } foreach $testpassed ($test->findnodes('./skip')) { $failure_type = $testfailure->getAttribute('type +'); $failure_temp = $testfailure->getAttribute('mess +age'); }

the variable $testfailure first iterates over ‘failure’ nodes, but then — without being reinitialised — is accessed in the following foreach loop to find the failure type and message for ‘skipped’ nodes. I assume this is what was meant:

foreach $testpassed ($test->findnodes('./skip')) { $failure_type = $testpassed->getAttribute('type' +); # ^^^^^^^^^^^ $failure_temp = $testpassed->getAttribute('messa +ge'); # ^^^^^^^^^^^ }

This is the sort of error that is easy to pick up if you have use strict; at the head of your code. You should always do this, and put use warnings; there as well.

(Actually, the logic of this whole section of code looks highly dubious to me. It iterates over ‘failure’ nodes and sets $failure_type and $failure_temp once only, then iterates over ‘skipped’ nodes and overwrites the values of these variabes, and so on.)

The problem you are seeing comes from a similar cut-and-paste error, but in this case it’s made harder to see by the way the code is formatted. Here is the skeleton of the problem section:

if ($error_type ne '') { ... } elsif ($failure_type ne '') { ($failure_message, $junk) = split(/^/, $failure_temp, 2); chomp $failure_message; $failure_message =~ s/,/|/g; print OUTFILE "FAILED, $failure_type, $failure_message\n"; } elsif ($failure_type ne '') { ... $failure_message =~ /skip/; print OUTFILE "SKIPPED, $failure_type, $failure_message\n"; } else { print OUTFILE "PASSED\n"; }

Can you see the problem now? The condition in the second elsif clause is identical to the condition in the first elsif clause, so the second one will never be true and the section dealing with skipped nodes will never be entered. You need to change the condition to catch the ‘skipped’ case. (I can’t tell you what the condition should be, as I don’t sufficiently understand how the script is supposed to be working.)

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re: Parsing a file.. having trouble. by Athanasius
in thread Parsing a file.. having trouble. by Everlong

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.