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:
-- Douglas Hunter#!/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"; } }
In reply to Re: Splitting a long string
by dug
in thread Splitting a long string
by uvnew
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |