Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by chromatic (Archbishop)
on Apr 21, 2000 at 20:12 UTC ( #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? - Answer 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?
[Lady_Aleena]: Sorry for the name typo LanX.
[LanX]: never lad_ena!
[LanX]: ;)
[Lady_Aleena]: IMO, Fancy::Join:: Grammatical isn't bad, but RolePlaying:: WorldBuilding:: WorldBuildersGuide book::ClimateTerra inSubsistance is on the long side.
[Lady_Aleena]: I'm still in reorganizing/ renaming mode.

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2017-05-24 22:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?