Quick and dirty? Keep arrayrefs in the Outcond array. UNTESTED changes to the code:
... my @Outcond = ([]); #array for out conditions ... sub Outcond { my( $twig, $s )= @_; push(@{$Outcond[$#Outcond]},( $s->att('NAME'))); } ... sub Output { my( $twig, $s )= @_; push(@Jobs,( $s->att('JOBNAME'))); push(@Time,($s->att('TIMEFROM'))); push(@Desc,($s->att('DESCRIPTION'))); push(@Days,($s->att('DAYS'))); push(@Outcond, []); #At the end you will have a trailing empty arr +ayref at the end of @Outcond, but you don't need to worry about that +given the way you print your output } ... sub write_text { my $worksheet = shift; ... #loop all data and output in correct positions while ($count <= (scalar(@Jobs))) { $worksheet->write($ygroup, $xgroup, $group[$count-1]); $worksheet->write($yjobs++, $xjobs, $Jobs[$count-1]); $worksheet->write($yDays++, $xDays, $Days[$count-1]); $worksheet->write($yTags++, $xTags, $Tag[$count-1]); $worksheet->write($yStarting++, $xStarting, $Time[$count-1]); $worksheet->write($yDesc++, $xDesc, $Desc[$count-1]); $worksheet->write($yOut++, $xOut, join(',', @{$Outcond[$count- +1]}); $worksheet->write($yIn++, $xIn, $Incond[$count-1]); $ygroup = ($ygroup+$yjobs); $count++; } }
But generally, it would be better to store corresponding data (i.e. data belonging to every JOB element) together in one structure (or object). Having the data in 8 distinct arrays really hurts the eye. And it's not only non-elegant, you may easily get into problems when a child element is missing - that would mix up your arrays.

Also, XML::Twig is excellent in processing XML documents as they come. You might output your record to excel every time the whole job element has been parsed (i.e. in the Output sub). If you want to store all the data, another XML library may be better, personally, I'd choose XML::Simple.


In reply to Re: XML help by pjotrik
in thread XML help by Anonymous Monk

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.