$csv = Text::CSV_XS->new({binary => 1}); #### $csv = Text::CSV_XS->new({binary => 1}); while () { #while ($csv->parse($_)) if (/"X"/) { #The trash data has these 3 characters in it print "THERE IS TRASH IN THE FILE:: $_\n"; } elsif ($first_line==1){ $first_line=0; } else { #Now to deal with the data I want to keep if($csv->parse($_)) { #checks to see if data exists in $_ and +parses it if it does my @fields=$csv->fields; # puts the values from each field in an +array my $elements=@fields; #gets the number of elements in the arra +y my $x=0; # for ($x=0;$x<$elements;$x++) { # print "$fields[$x]\t"; print "\n"; if ($fields[$x]=~ m/\d+/i){ print "LOGID: $fields[$x++]\n"; print "LOGDATE: $fields[$x++]\n"; print "EMPID: $fields[$x++]\n"; print "CATEGORY: $fields[$x++]\n"; print "SUBCAT: $fields[$x++]\n"; print "OS: $fields[$x++]\n"; print "DESCR: $fields[$x++]\n"; print "ACTION: $fields[$x++]\n"; print "ASSIGNTO: $fields[$x++]\n"; print "STATUS: $fields[$x++]\n"; } else { print "\problematic field found "; $counterp++; print "LOGID: $fields[$x++]\n"; # $asdf=<>; } # } $counter++; } } }