title: How do I efficiently parse a CSV file in Perl?
body: <p>I'm working on a project that involves parsing a large csv formatted file in Perl and am looking to make things more efficient.</p>
  
  <p>My approach has been to <code>split()</code> the file by lines first, and then <code>split()</code> each line again by commas to get the fields. But this suboptimal since at least two passes on the data are required. (once to split by lines, then once again for each line). This is a very large file, so cutting processing in half would be a significant improvement to the entire application.</p>
  
  <p>My question is, what is the most time efficient means of parsing a large CSV file using only built in tools?</p>
  
  <p>note: Each line has a varying number of tokens, so we can't just ignore lines and split by commas only. Also we can assume fields will contain only alphanumeric ascii data (no special characters or other tricks). Also, i don't want to get into parallel processing, although it might work effectively.</p>
  
  <p><strong>edit</strong></p>
  
  <p>It can only involve built-in tools that ship with Perl 5.8. For bureaucratic reasons, I cannot use any third party modules (even if hosted on cpan)</p>
  
  <p><strong>another edit</strong></p>
  
  <p>Let's assume that our solution is only allowed to deal with the file data once it is entirely loaded into memory.</p>
  
  <p><strong>yet another edit</strong></p>
  
  <p>I just grasped how stupid this question is. Sorry for wasting your time. Voting to close.</p>