# chop the inputs to remove the trailing \n my $l = ; chop($l); .. and so on.. # use while to loop over the lines in the file open MAPFILE "$sdtfile" or die; while () { my ($date, $time, $lot, $waf, $ts, $sstep, $machine, $prog, $product, $plnfile, $striping) = split(/,/, $_); if (..) { # rest of the program } }