This part of your code:
my @file = <INFILE>; my $reg = s/[^,]*\.(\S*)//; while (my $line = <INFILE>){ chomp $line; my $wholefile = $line.$_ foreach(@file); print OUTFILE $wholefile; }
is most probably wrong anyway, so you might as well rewrite it completely. Either slurp the file into an array and then process the array elements, or read the file line by line and process each line in turn, but don't try to do both. Here, you read the whole file into the @file array and then try to read from that file again line by line, this is not going to work. In addition, in the while loop that is supposed to read the file, you loop on the array again, which is a faulty logic. You are "saved" from that silly process only because the while loop will in fact not loop on the file handler, because the file handler is exhausted at this point.

In reply to Re^3: Removing everything before the first comma separator on each line of a text file by Laurent_R
in thread Removing everything before the first comma separator on each line of a text file by zodell

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.