Text::Wrap::Smart::XS - Wrap text fast into chunks of similar length
use Text::Wrap::Smart::XS ':all'; # or use Text::Wrap::Smart::XS qw(exact_wrap fuzzy_wrap); @chunks = exact_wrap($text, $wrap_at); @chunks = fuzzy_wrap($text, $wrap_at);
Text::Wrap::Smart::XS is the faster companion of Text::Wrap::Smart.
Text::Wrap::Smart::XS
Text::Wrap::Smart
@chunks = exact_wrap($text [, $wrap_at ]);
Wrap a text of varying length into exact chunks (except the last one, which consists of the remaining text).
Optionally a wrapping length may be specified; if no length is supplied, a default of 160 will be assumed.
@chunks = fuzzy_wrap($text [, $wrap_at ]);
Wrap a text of varying length into chunks of fuzzy length (the boundary is normally calculated from the last whitespace preceding the wrapping length, and if no remaining whitespace could be find, the end of text; if the wrapping length is smaller than the size of a word, greedy wrapping will be applied: all characters until the first whitespace encountered form a chunk).
exact_wrap(), fuzzy_wrap() are exportable.
exact_wrap(), fuzzy_wrap()
:all - *()
The wrapping length will not be applied directly, but is used to calculate the average length to split text into chunks.
Text will be normalized prior to being processed, i.e. leading and trailing whitespace will be chopped off before each remaining whitespace is converted to a literal space.
Text::Wrap, Text::Wrap::Smart
Steven Schubiger <schubiger@cpan.org>
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
To install Text::Wrap::Smart::XS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::Wrap::Smart::XS
CPAN shell
perl -MCPAN -e shell install Text::Wrap::Smart::XS
For more information on module installation, please visit the detailed CPAN module installation guide.