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

Re: How to split a string into two lines, intelligently

by Andrew Coolman (Hermit)
on Oct 09, 2008 at 22:41 UTC ( #716331=note: print w/ replies, xml ) Need Help??


in reply to How to split a string into two lines, intelligently

This one might work if the characters are separated by spaces:

@arr = split (/\s/,$string); $part1 = (); $part2 = (); $len = 0; while (($len += 1 + length($part = shift @arr)) < 50) { $part1 .= "$part "; } $part2 = join(' ', @arr);

Regards,
s++ą  ł˝ ął. Ş ş şą Żľ ľą˛ş ą ŻĽąş.}++y~-~?-{~/s**$_*ee


Comment on Re: How to split a string into two lines, intelligently
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2015-08-01 01:02 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 (285 votes), past polls