in reply to File Reading

Any ideas how to tackle this problem is welcome
Create a hash of arrays, where the hash keys are the elements one the first line, and the array elements are values from each column respectively. Read perldata, perlfaq4.
$ perl -w 641872.pl $VAR1 = { 'EYES' => [ 'BLUE', 'BROWN' ], 'AGE' => [ '32', '54' ], 'HAIR' => [ 'BLONDE', 'BROWN' ] };
Update: The implementation is intentionally excluded since this is an obvious homework question. Memory concerns are considered out of scope. In real life I would probably use cut (Unix).
--
Andreas

Replies are listed 'Best First'.
Re^2: File Reading
by svenXY (Deacon) on Oct 01, 2007 at 13:34 UTC
    Hi,
    ++andreas1234567, yes, that will work, but you will always fill your memory with a lot of unnecessary data before you actually output any data.
    Without saying too much (to not make the OP's homework too easy ;-)), I'd first find out which column is actually searched for, then go through the rest of the file line by line and print the only column that is requested.
    No building up of a huge hash...
    Regards,
    svenXY