No::Worries::String - string handling without worries
use No::Worries::String qw(*); # escape a string printf("found %s\n", string_escape($data)); # produce a nice output (e.g "1 file" or "3 files") printf("found %s\n", string_quantify($count, "file")); # format a table print(string_table([ [1, 1, 1], [2, 4, 8], [3, 9, 27], ], header => [qw(x x^2 x^3)])); # trim a string $string = string_trim($input);
This module eases string handling by providing convenient string manipulation functions.
This module provides the following functions (none of them being exported by default):
return a new string with all potentially non-printable characters escaped; this includes ASCII control characters, non-7bit ASCII and Unicode characters
assuming that STRING is an English noun, returns its plural form
assuming that STRING is an English noun, returns a string saying how much of it there is; e.g. string_quantify(2, "foot") is "2 feet"
string_quantify(2, "foot")
"2 feet"
transform the given table (a reference to an array of arrays of strings) into a formatted multi-line string; supported options:
align: array reference of alignment directions (default: left)
align
colsep: column separator string (default: " | ")
colsep
header: array reference of column headers (default: none)
header
headsep: header separator (default: "=")
headsep
indent: string to prepend to each line (default: "")
indent
return a new string with leading and trailing spaces removed
No::Worries.
Lionel Cons http://cern.ch/lionel.cons
Copyright (C) CERN 2012-2016
To install No::Worries, copy and paste the appropriate command in to your terminal.
cpanm
cpanm No::Worries
CPAN shell
perl -MCPAN -e shell install No::Worries
For more information on module installation, please visit the detailed CPAN module installation guide.