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


I want to read in certain columns from a table, header like:
Date Time Weight Height
12 12:00 120 1.20
13 12:00 80 1.10
14 12:00 60 1.00
...
I only need Weight and Height two columns, How can I make it?
Please help!
  • Comment on How can I read only certain columns of a table

Replies are listed 'Best First'.
•Re: How can I read only certain columns of a table
by merlyn (Sage) on May 15, 2002 at 00:33 UTC
    Given that this is probably Homework, I feel qualified to make the following comment:
    I always wonder, how do you tell the certain columns from the uncertain ones?
    {grin}

    -- Randal L. Schwartz, Perl hacker

Re: How can I read only certain columns of a table
by rob_au (Abbot) on May 15, 2002 at 00:19 UTC
Re: How can I read only certain columns of a table
by perlplexer (Hermit) on May 15, 2002 at 00:22 UTC
    When is this homework due? ;)
    # assuming the table you're talking # about is in a file... #read perldoc -f open open FH, "<file.dat" or die "Can't open : $!\n"; while (<FH>){ # read perldoc -f split my ($weight, $height) = (split)[2,3]; print "W: $weight H: $height\n"; } close FH;
    --perlplexer
Re: How can I read only certain columns of a table
by Anonymous Monk on May 15, 2002 at 00:20 UTC
    Well, that's why you're going to school now, isn't it, homework boy? To learn, preferably by doing?