Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Answer: How can I split a line close to a certain length, but on a word boundary?

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

Q&A > strings > How can I split a line on word boundaries closest to a certain length? contributed by chromatic

The Text::Wrap module might prove useful to you. Your code might look like this:
use Text::Wrap qw(wrap 140 'wrap'); @strings = split/\n\n/, wrap($text);

Comment on Answer: How can I split a line close to a certain length, but on a word boundary?
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 taking refuge in the Monastery: (6)
As of 2015-07-01 22:22 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 (24 votes), past polls