Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How can I split a string into chunks of 4 characters

by Random_Walk (Prior)
on Dec 06, 2013 at 16:31 UTC ( [id://1066006]=note: print w/replies, xml ) Need Help??


in reply to How can I split a string into chunks of 4 characters

use strict; use warnings; use 5.010; my $len = 4; my $string = "01234abc"; for (0 .. (length $string - $len) ) { say substr $string, $_, $len; } # or in an array my @chunks = map {substr $string, $_, $len} (0 .. (length $string - $l +en) ); say join "<>", @chunks;

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2026-04-18 17:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.