in reply to Re: Reading a huge input line in parts (Handles multi-digit numbers!)
in thread Reading a huge input line in parts
Could this not be simplified?
sub genBufferedGetNum { return sub { @buf = do{ local $/ = \10; split ' ', <> }; return @buf; }; } my $getNum = genBufferedGetNum(); while( my @part = $getNum->() ) { print @part, "\n"; }
I shortened the buffer size for testing purposes
$: cat tb.dat 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 $:
$: cat tb.dat | perl tb.pl 01234 56789 01234 56789 01234 56789 0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Reading a huge input line in parts (Handles multi-digit numbers!)
by BrowserUk (Patriarch) on May 04, 2015 at 22:37 UTC |