This is part of my very nasty code for printing the right stuff for one VP, but it is highly useless for the entire file
No, you almost have it (at least if I understood correctly what you want to do). Your code is reading the file line by line, which is what you need. For each line, you just need to pickup the relevant fields and print them out.

You only need to open a new output file for each input record.

You did not say how you want to name your files, so I will pick up the first field as it seems to be a line number.

while (<REIN>) { chomp(); my @we = split(/\t/); my $out_file_name = "out_file_nr_$we[0]"; open my $RAUS, ">", $out_file_name or die "could not open $out_fil +e_name $!"; my $fix = "$we[0]\t$we[1]\t$we[2]\t$we[3]"; my $out1 = "$we[4]\t$we[5]\t$we[6]\t$we[7]\t$we[8]\t$we[9]\t$we[10 +]\t$we[11]\t$we[12]"; print $RAUS $fix ."\t" .$out1."\n"; close $RAUS; } close(REIN)
I do not understand, though, why you are splitting the data into fields and then join them back into the original format before printing it. So this could be simply:
while (<$REIN>) { my $out_file_name = "out_file_nr_[$.]"; # $. is the line number on + the last read file handle open my $RAUS, ">", $out_file_name or die "could not open $out_fil +e_name $!"; print $RAUS $_; close $RAUS; } close(REIN)
Or did I miss something in your requirement?

In reply to Re^3: Spliting Table by Laurent_R
in thread Spliting Table by tschelineli

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.