in reply to Re^2: print content of array individually after parsing multiple input files
in thread print content of array individually after parsing multiple input files

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