in reply to Re: Read File In Four-Line Chunks / TMTOWTDI / Golf
in thread Read File In Four-Line Chunks / TMTOWTDI / Golf

Instead of slurping everything at once, just read the handle four times. Then you can deal with multi-gigabyte phonebooks.

while (my ($name,$address,$phone,$fax) = (<FILE>, <FILE>, <FILE>, <FIL +E>)) { #work with named vars (don't forget chomp) }

Update: just did a little test, and it does one iteration and stops. Hm.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re: Re: Re: Read File In Four-Line Chunks / TMTOWTDI / Golf
by Lachesis (Friar) on Jun 10, 2003 at 14:31 UTC
    You're using <FH> in a list context so it would read in the entire file in the first iteration
    Update: apologies I'm speaking rubbish there. I did a quick test my self and it picks up the data you would expect but only does iterate the once.