RECORD: while (){ # read data 1 byte at a time for (my $i=0;$i < length($_);$i++) { $byte = substr($_, $i, 1); if ($byte eq "\""){ $i++; $next_byte = substr($_, 1, $i) if ($next_byte ne ",") { $quoting = 1; } else { $quoting = 0; } if ($quoting) { print $byte$next_byte; next; } else { print $nextbyte next; } } }elsif ($byte =~ /\n/) { $quoting = 0; next RECORD; } else { print $byte; } $quoting = 0; }