I'm sorry to say there are a lot of issues with your code that make it really hard to read and debug. If you want help with the code, the first thing you need to do is Use strict and warnings, and second you should run it through perltidy and get rid of all those extra blank lines. You've got some unused handles (e.g. DIR and OUTPUT) and you'll need to decide on the variables' scopes. Plus a few more things, like missing error handling (... or die) on opens, ...

I'm still a little unclear on the problem statement, but I can give a general answer to what was posted below:

use warnings; use strict; my @errors; for my $input (1..3) { # main loop, just a demo # do something with $input here print "pattern$input\n"; if ($input%2) { # whatever your error condition is push @errors, "error$input"; } } print "\n#errors\n"; # main loop over, now output @errors for my $error (@errors) { print "$error\n"; } print "cellpattern\n";

As you operate over the input to produce the output, you accumulate the errors in @errors, and then, after the main loop, you loop over @errors to output the contents of that array. The output of the above snippet is:

pattern1 pattern2 pattern3 #errors error1 error3 cellpattern

In reply to Re^3: print content of array individually after parsing multiple input files by Anonymous Monk
in thread print content of array individually after parsing multiple input files by teddy6507

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.