note
dug
<p>Another way to do this is to treat your data as an "in memory" file (see perldoc -f open). Setting the INPUT_RECORD_SEPARATOR variable to a reference to an integer will make the readline operator read that many bytes, or as many as it can until EOF. Putting that all together gives us:</p>
<code>
#!/usr/bin/perl
use warnings;
use strict;
my $string = "x" x 100_400;
{
open ( my $sth, "<", \$string ) or die $!;
local $/ = \1_000;
while ( my $chunk = <$sth> ) {
print $chunk, "\n";
}
}
</code>
-- Douglas Hunter
634273
634273