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.
In reply to Re: Reading a huge input line in parts
by aaron_baugher
in thread Reading a huge input line in parts
by kroach
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |