Section: User Contributed Perl Documentation (3)
MDK::Common::String - formatting functions
use MDK::Common::String qw(:all);
- bestMatchSentence(STRING, LIST)
finds in the list the best corresponding string
- formatList(INT, LIST)
if the list size is bigger than INT, replace the remaining elements with ``...''.
formatList(3, qw(a b c d e)) # => ``a, b, c, ...''
the string is something like ``error at foo.pl line 2'' that you get when
catching an exception. formatError will remove the ``at ...'' so that you can
nicely display the returned string to the user
the TIME is an epoch as returned by "time", the formatted time looks like ``23:59:00''
remove ``\n''s when the next line doesn't start with a space. Otherwise keep
``\n''s to keep the indentation.
handle carriage return just like LaTeX: merge lines that are not separated by
an empty line
- begins_with(STRING, STRING)
return true if first argument begins with the second argument. Use this
instead of regexps if you don't want regexps.
begins_with(``hello world'', ``hello'') # => 1
- warp_text(STRING, INT)
return a list of lines which do not exceed INT characters
(or a string in scalar context)
warp_text at a default width (80)