NAME SHARYANTO::String::Util - String utilities VERSION version 0.24 FUNCTIONS trim_blank_lines($str) => STR Trim blank lines at the beginning and the end. Won't trim blank lines in the middle. Blank lines include lines with only whitespaces in them. ellipsis($str[, $maxlen, $ellipsis]) => STR Return $str unmodified if $str's length is less than $maxlen (default 80). Otherwise cut $str to ($maxlen - length($ellipsis)) and append $ellipsis (default '...') at the end. indent($indent, $str, \%opts) => STR Indent every line in $str with $indent. Example: indent(' ', "one\ntwo\nthree") # " one\n two\n three" %opts is optional. Known options: * indent_blank_lines => BOOL (default 1) If set to false, does not indent blank lines (i.e., lines containing only zero or more whitespaces). linenum($str, \%opts) => STR Add line numbers. For example: 1|line1 2|line2 | 4|line4 Known options: * width => INT (default: 4) * zeropad => BOOL (default: 0) If turned on, will output something like: 0001|line1 0002|line2 | 0004|line4 * skip_empty => BOOL (default: 1) If set to false, keep printing line number even if line is empty: 1|line1 2|line2 3| 4|line4 pad($text, $width[, $which[, $padchar[, $truncate]]]) => STR Return $text padded with $padchar to $width columns. $which is either "r" or "right" for padding on the right (the default if not specified), "l" or "left" for padding on the right, or "c" or "center" or "centre" for left+right padding to center the text. $padchar is whitespace if not specified. It should be string having the width of 1 column. FAQ What is this? This distribution is part of SHARYANTO::Utils, a heterogenous collection of modules that will eventually have their own proper distributions, but do not yet because they are not ready for some reason or another. For example: alpha quality code, code not yet properly refactored, there are still no tests and/or documentation, I haven't decided on a proper name yet, etc. I put it on CPAN because some of my other modules (and scripts) depend on it. And I always like to put as much of my code in functions and modules (as opposed to scripts) as possible, for better reusability. You are free to use this, but beware that things might get moved around without prior warning. I assure you that this is not a vanity distribution :-) SEE ALSO SHARYANTO::Utils AUTHOR Steven Haryanto COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Steven Haryanto. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.