Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Answer: How do I split up a long string with no spaces?

( #79958=categorized answer: print w/ replies, xml ) Need Help??

Q&A > regular expressions > How do I split up a long string with no spaces? contributed by Daddio

You can also create a neat array of the strings using this:

my $string = "thisisalongstringofcharacters"; my (@strings) = split /(.{5})/,$string;

Season the '5' in the split to taste. Gives a nice array for use in whatever you need it for.

Comment on Answer: How do I split up a long string with no spaces?
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (21)
As of 2015-07-02 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (39 votes), past polls