Try setting $len to 5. You'll see that the 'tight' version fails to wrap correctly under certain circumstances like this
Wrapping:
@[0;7mCoruscate@[0m says this is a test of the line wrapping code
Tight code1:
@[0;7mCoruscate@[0m says this is a test of the line wrapping code
Tight code:
@[0;7mCorus
cate@[0m says this is a test of the line wrapp
ing code
which suggested to me that the regexes be executed in opposite order
Wrapping:
@[0;7mCoruscate@[0m says this is a test of the line wrapping code
Tight code1:
@[0;7mCorus
cate@[0m says this is a test of the line wrapp
ing code
Tight code:
@[0;7mCorus
cate@[0m
says
this
is a
test
of
the
line
wrapp
ing
code
which seems to do the trick. I believe the first regex gets stymied by lines that have to be split many times at a space, as well as being split many times inside a word.
---
demerphq
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|