http://www.perlmonks.org?node_id=127219


in reply to I'm so confused

st4k,
The problem is the way you have your data entered into the files. I can tell that your files look like this:
file1:    file2:    file3:
one\n     four\n    seven\n
two\n     five\n    eight\n
three^Z   six^Z     nine^Z
The ^Z represent the end of file character. So that when you dump the array using:
print @out;
There are no line breaks between three-four and six-seven. To correct this you should chomp each read and store all the data without newlines:
for (my $i = 0; $i < $num; $i++) { print "$ARGV[$i]\n"; open (FH, "$ARGV[$i]") || die "Cant open: $!"; while (<FH>) { chomp; ## <- added this line push @out, lc; } close FH || die "Cant open: $!"; }
To print this as you would expect, use this instead:
print join (@out,"\n");
This tells print to make one long string with a newline inserted between each element of @out.

Hope this helps.

--Jim