in reply to Reading a huge input line in parts
A couple simple if hackish ways to handle this:
The ' 'x eof may be omitted if \n endings are guaranteed.use 5.014; $/ = \8192; while (<>) { # like so state $buf .= $_ . ' 'x eof; $buf =~ s{ \s* (\S+) \s }{ process($1), "" }xge; } while (<>) { # ..or so state $buf .= $_ . ' 'x eof; $buf = pop( my $tok = [split ' ', $buf, -1] ); process(@$tok); } sub process { say for @_ }
|
|---|