in reply to 8 in a line...
I'd probably go the unpack route, but walking down substrings is sometimes faster.
use constant CHUNK => 8; for (my $x = 0; $x < length($str) / CHUNK; ++$x) { print substr($str, $x * CHUNK, CHUNK), "\n"; }
For people who have an aversion to C-style loops in Perl, the above can also be recast as a statement modifier:
print substr($str, $_ * CHUNK, CHUNK), "\n" for 0 .. length($str) / CHUNK;
• another intruder with the mooring in the heart of the Perl
|
|---|