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.