Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: 8 in a line...

by grinder (Bishop)
on Jun 20, 2008 at 13:42 UTC ( [id://693161]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://693161]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found