Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

( #8822=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 poznick

and true to the perl motto, here's yet another (much simpler) way to do it:
@text = $messagebody =~ /(.{1,140}\W)/gms;

  • Comment on Answer: How can I split a line close to a certain length, but on a word boundary?
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 cooling their heels in the Monastery: (5)
As of 2016-06-27 01:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (333 votes). Check out past polls.