#! perl -slw use strict; my $data = do{ local $/; }; my $noOfFieldsMinus1 = 5; my @records = $data =~ m[ ( (?: (?: "[^"]+" ##" | [^,]+ ) , ){$noOfFieldsMinus1} (?: "[^"]+" ##" | \S+ ) ) \s+ ]gx; print for @records; __DATA__ "Business Date","Location Name","Revenue Center Name","Tender Count","Tender Name","Tender Total" 2007-05-14 00:00:00.0,"Aville","x",300,"b",6899 2007-05-14 00:00:00.0,"Aville","x",6,"c",198.50 2007-05-14 00:00:00.0,"Aville","b",290,"Cash",12336.10 2007-05-14 00:00:00.0,"Bville","c",14,"d",958.40 #### C:\test>615576 "Business Date","Location Name","Revenue Center Name","Tender Count","Tender Name","Tender Total" 2007-05-14 00:00:00.0,"Aville","x",300,"b",6899 2007-05-14 00:00:00.0,"Aville","x",6,"c",198.50 2007-05-14 00:00:00.0,"Aville","b",290,"Cash",12336.10 2007-05-14 00:00:00.0,"Bville","c",14,"d",958.40