in reply to Re:{4} how do I line-wrap while copying to stdout?
in thread how do I line-wrap while copying to stdout?
Suppose you were wrapping the following at 10 characters:
The proper result is:abcdefghijklm nopqrstuvwxyz
However, the solutions in the Benchmark will produce:abcdefghij klm nopqrstuvw xyz
The regex solution is easy to fix: print DUMP map "$_\n", $a=~/(.{1,80})/g; The substr() solution requires more work to get right, such as splitting on newlines and wrapping each line separately, or sticking any partial lines back onto to the beginning of the string after each substr().abcdefghij klm nopqrs tuvwxyz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re:{6} how do I line-wrap while copying to stdout?
by jeroenes (Priest) on Apr 21, 2001 at 02:15 UTC |