Tie::Handle::CSV

Update 18/8/08: the code in this post is corrupted with smilies…working on it

Bioinformaticians like tabular data; plain ASCII text delimited by tabs, commas or whatever. In the past, I’ve written an awful lot of scripts that begin something like this:

open IN, $file;
  while( <in> ) {
    chomp;
    my @line = split("\t", $_);
## count fields in a line and check for header
    if( $#line == 6 && $line[0] ne "ID" ) {
## do something with fields
                                          }
                }
close IN;

Bad programmer! Why not use one of the many Perl modules for handling CSV files, such as Tie::Handle::CSV?
Read the rest…