Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

If I have table of data, how would I go about extracting a particular column from the table without loading each line into and array because the application I'm working on has different length colums. table is tab delimited if that helps. ie. how would I extract gene2 into an array?
gene1 score1 gene2 score2 gene3 score3

cangt 39 cagnt 68 cangt 6

agntc 24 agtnc 69 agtnc 7

ancgt 19 tancg 54

gntca 2 cangt 83

tnacg 3
---Matt

Replies are listed 'Best First'.
Re: table column into an array
by grep (Monsignor) on Oct 24, 2002 at 17:26 UTC

    You'll want to use split and a list slice.

    my $rtn = ( split(/\t/,$line) )[2]

    I used 2 since you want the 3rd element out and we start counting at 0

    slices are explained in perldata



    grep
    Mynd you, mønk bites Kan be pretti nasti...