I have N files, each of them of the form:
line_number var1 var2 .... varN
I am reading all the files from an ARGV list
for my $file (@files) { while (<IN>) $line_number= $list[0]; push @($var1{$i}), $list[1]; etc... } close IN; }
I want to create for each variable an output file that would contain something like:
for my $j (0...Nlines-1){ open(OUT, ">", "./var1.dat") print OUT "$line_number \t $var1{file1}[$i] \t $var1{file2}[$i] \t ... + $var1{fileN}[$i]\n" } close OUT;
What is the way to write in the same line of the output file
in different columns the information for the same
variable taken from different input files?

Is there a way to open a $NEWLINE variable and keep appending
to it values from each of the input file and, after reading
from all the input files, closing the line
and then writing the line in the output file?

Thank you,
Ioana


In reply to append to a line arrays read from N different input files by ioana007

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.