in reply to Re^2: Removing everything before the first comma separator on each line of a text file
in thread Removing everything before the first comma separator on each line of a text file

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.
  • Comment on Re^3: Removing everything before the first comma separator on each line of a text file
  • Download Code