in reply to Re: Read File In Four-Line Chunks / TMTOWTDI / Golf
in thread Read File In Four-Line Chunks / TMTOWTDI / Golf
Nice. You can prevent it from dealing with partial records at the end of the input too...
while ( 4 == scalar grep {$_ = <FH>; chomp} my($name,$address,$phone,$ +fax) ) { # Do stuff }
Update: See Aristotle's comments below. This will fail to process a four line record if the last record is missing an EOL. Also, using an explicit scalar is superfluous... and if you are already torturing your maintenance programmer with this construct, why be explicit? :-)
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Read File In Four-Line Chunks / TMTOWTDI / Golf (bug with EOL-less last line)
by Aristotle (Chancellor) on Jun 07, 2003 at 10:23 UTC |