in reply to Reading a huge input line in parts
You could probably gain quite a bit of speed by reading in chunks of the line instead of one character at a time. That way you can use the normal split function. Something like this, but with as large a buffer value as your system can handle well:
#!/usr/bin/env perl use 5.010; use strict; use warnings; my $l; # chunk of a line my $tiny_buffer = 8; # tiny buffer for testing while( read DATA, $l, $tiny_buffer ){ for (split ' ', $l){ if( $_ eq '0' ){ say 'Reached the end'; exit; } say "; $_ ;"; # do stuff with the digit } } __DATA__ 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 0
Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading a huge input line in parts
by kroach (Pilgrim) on May 04, 2015 at 15:53 UTC | |
by Laurent_R (Canon) on May 04, 2015 at 18:05 UTC | |
by aaron_baugher (Curate) on May 04, 2015 at 22:36 UTC |