SHARYANTO::String::Util - String utilities
This document describes version 0.27 of SHARYANTO::String::Util (from Perl distribution SHARYANTO-String-Util), released on 2014-05-22.
Trim whitespaces (including newlines) at the beginning of string. Equivalent to:
$str =~ s/\A\s+//s;
Trim whitespaces (not including newlines) at the beginning of each line of string. Equivalent to:
$str =~ s/^\s+//mg;
Trim whitespaces (including newlines) at the end of string. Equivalent to:
$str =~ s/[ \t]+\z//s;
Trim whitespaces (not including newlines) at the end of each line of string. Equivalent to:
$str =~ s/[ \t]+$//mg;
ltrim + rtrim.
ltrim_lines + rtrim_lines.
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.
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 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).
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
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.
$text
$padchar
$width
$which
$padchar is whitespace if not specified. It should be string having the width of 1 column.
Quote or encode $str to the Perl double quote (qq) literal representation of the string. Example:
$str
qq
say qqquote("a"); # => "a" say qqquote("a\n"); # => "a\n" say qqquote('"'); # => "\"" say qqquote('$foo'); # => "\$foo"
This code is taken from quote() in Data::Dump. Maybe I didn't look more closely, but I couldn't a module that provides a function to do something like this. String::Escape, for example, provides qqbackslash but it does not escape $.
quote()
qqbackslash
$
Given a list of strings, return common prefix.
Given a list of strings, return common suffix.
SHARYANTO
Please visit the project's homepage at https://metacpan.org/release/SHARYANTO-String-Util.
Source repository is at https://github.com/sharyanto/perl-SHARYANTO-String-Util.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=SHARYANTO-String-Util
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Steven Haryanto <stevenharyanto@gmail.com>
This software is copyright (c) 2014 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.
To install SHARYANTO::String::Util, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SHARYANTO::String::Util
CPAN shell
perl -MCPAN -e shell install SHARYANTO::String::Util
For more information on module installation, please visit the detailed CPAN module installation guide.