in reply to Tiny little paragraph wrapper

Your version chops off the beginning of words that are longer than the wrap length, instead of temporarily increasing the wrap length like the original snippet does.

For the text "Check out http://www.perlmonks.org/?node_id=438189 (it has nice line-wrapping snippet).", here is the output:

method 1:

Check out http://www.perlmonks.org/?node_id=438189 (it has nice line-wrapping snippet).
method 2:
Check out .org/?node_id=438189 (it has nice line-wrapping snippet).

Replies are listed 'Best First'.
Re^2: Tiny little paragraph wrapper
by GrandFather (Saint) on May 31, 2005 at 03:37 UTC
    Try this regex s/(.{5,12}\s+)/$1\n/g. On the sample text it gives: :-)
    Check out http://www.perlmonks.org/?node_id=438189 (it has nice line-wrapping snippet).