NAME

Text::Wrap::Smart::XS - Wrap text fast into chunks of similar length

SYNOPSIS

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);

DESCRIPTION

Text::Wrap::Smart::XS is the faster companion of Text::Wrap::Smart.

FUNCTIONS

exact_wrap

@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.

fuzzy_wrap

@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).

Optionally a wrapping length may be specified; if no length is supplied, a default of 160 will be assumed.

EXPORT

Functions

exact_wrap(), fuzzy_wrap() are exportable.

Tags

:all - *()

BUGS & CAVEATS

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.

SEE ALSO

Text::Wrap, Text::Wrap::Smart

AUTHOR

Steven Schubiger <schubiger@cpan.org>

LICENSE

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/