in reply to whats the best way to query/extract fields from a tab delimited file

use split() and the diamond operator:
use strict; my $filename = 'test.tsv'; open (FILE, $filename); my @headers = split(/\t/,<FILE>); while (my $line = <FILE>) { my @fields = split(/\t/,$line); } close (FILE);
you might also want to use chomp().

An (somewhat more complex) alternative is to use DBI and DBD::CSV.

  • Comment on Re: whats the best way to query/extract fields from a tab delimited file
  • Download Code

Replies are listed 'Best First'.
Re: Re: whats the best way to query/extract fields from a tab delimited file
by aussieaubs (Initiate) on Oct 31, 2003 at 19:50 UTC
    wow thank you very much for the info I il look into it. another word to put on my list - split and Diamond operator