while (my $row = $aCSV->getline ($ORIG_CSV)) { #Test row and determine if there is data. If the first element is empty then that is the last line. #This should prevent errors, and drop the extraneous data at the end of the file. if ($row->[0] =~ /\S/ ) { # Remove extra newline from field 5, 6 and 11 unless preceded by a carriage return, fields start counting at Zero. # Field 6 and 11 replaces with space for readabililty of the data. $row->[4] =~ s/ (?[5] =~ s/ (?[10] =~ s/ (?[5] =~ s/ \Q,\E / /gx; # replace comma in field with space. This makes CSV easier to import. $row->[9] =~ s/ \QRevision : \E //gx; $row->[10] =~ s/ \Q,\E / /gx; # replace comma in field with space. This makes CSV easier to import. $row->[12] =~ s/ \QProduction Item: \E//gx; $row->[13] =~ s/ \x23 //gx; # hexidecimal 0x23 is "#" and this messes with the regex in one step, but two works. $row->[13] =~ s/ \QWO : \E //gx; # remove the remainder junk "WO : " $row->[14] =~ s/ \QCutlist color: \E //gx; # Some fields have extra whitespace. Lets clean that up because we want to print some of this data. $row->[5] =~ s/\h+/ /g; $row->[10] =~ s/\h+/ /g; # Something to test on $row->[5] /#[^ ]+/ # Testing print some fields. REMEMBER 1 aka Zero print "$row->[5]\t$row->[9]\t$row->[12]\t$row->[13]\n"; push @rows, $row; } else { last; } }