Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: How to split a string based on length or word boundary

by bcarroll (Pilgrim)
on Dec 21, 2012 at 03:08 UTC ( #1009842=note: print w/replies, xml ) Need Help??


in reply to Re: How to split a string based on length or word boundary
in thread How to split a string based on length or word boundary

That works! Thanks for the quick reply. I changed the elsif code to
print "| $_ |\n" for map substr( $_ . ' 'x$menuWidth, 0, $menuWidth ), + $text =~ m[(.{1,$menuWidth})\s+]g;

Replies are listed 'Best First'.
Re^3: How to split a string based on length or word boundary
by BrowserUk (Pope) on Dec 21, 2012 at 03:27 UTC

    As Athanasius pointed out above, you need to change that to:

    print "| $_ |\n" for map substr( $_ . ' 'x$menuWidth, 0, $menuWidth ), + $text =~ m[(.{1,$menuWidth})(?:\s+|$)]g; #..................................................................... +.............................^^^^^^^^^

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009842]
help
Chatterbox?
[Corion]: LanX: Maybe have an infinite-loop cmd file? Much easier than trying to manage that from within Perl IMO
[Corion]: Alternatively, relaunch the application from cron (or a Windows cron) every minute
[LanX]: will try infinite loop ...
[Corion]: :START ... goto START
[LanX]: oh .bat you mean?
[LanX]: obscure cult ...
[Corion]: LanX: cmd.exe is just another way to launch Perl
[LanX]: I know its a cult... and I repent it every time
[LanX]: But cygwin comes with path problems and powershell requires too much learning for me
[LanX]: eshell in emacs is often my resort in development

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2017-03-27 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.