SHARYA...g::Util(3pm)
π SHARYANTO::String::Util β the string glow-up toolkit π
okay bestie, sit DOWN, because this is a Perl module called SHARYANTO::String::Util and it's part of the User Contributed Perl Documentation crowd. It does string stuff. Glorious, mundane, deeply necessary string stuff. It's giving "utility drawer but make it cute". β¨
πΈ NAME πΈ
SHARYANTO::String::Util β String utilities. that's it, that's the whole name, no notes π
π¦ DESCRIPTION π¦
β¨ FUNCTIONS β¨
every single one of these is a bop, let's go one by one, no skipping, I promised π«Ά
ltrim($str) => STRβ trims whitespaces (newlines INCLUDED, she's thorough) off the beginning of the string. Equivalent to:
$str =~ s/\A\s+//s;
ltrim_lines($str) => STRβ trims whitespaces (newlines NOT included this time, she's selective) off the beginning of each line of the string. Equivalent to:
$str =~ s/^\s+//mg;
rtrim($str) => STRβ trims whitespaces (newlines included) off the end of the string. Equivalent to:
$str =~ s/[ \t]+\z//s;
rtrim_lines($str) => STRβ trims whitespaces (newlines not included) off the end of each line of the string. Equivalent to:
$str =~ s/[ \t]+$//mg;
trim($str) => STRβ literally justltrim+rtrim. the collab we deserved. πtrim_lines($str) => STRβltrim_lines+rtrim_lines. the line-flavored sequel. πtrim_blank_lines($str) => STRβ trims blank lines off the beginning and the end. it will NOT touch blank lines in the middle, she minds her business. and yes, "blank lines" counts lines that have nothing but whitespaces in them. πellipsis($str[, $maxlen, $ellipsis]) => STRβ returns$strcompletely unmodified if$str's length is less than$maxlen(default80). otherwise it cuts$strdown to ($maxlen - length($ellipsis)) and slaps$ellipsis(default'...') on the end. short king behavior, respectfully. βοΈindent($indent, $str, \%opts) => STRβ indents every line in$strwith$indent. example, because a girl loves a visual:
indent(' ', "one\ntwo\nthree") # " one\n two\n three"
%opts is optional. known options are:
indent_blank_lines => BOOL(default1) β if you set it to false, it does not indent blank lines (aka lines containing only zero or more whitespaces). zero. or more. whitespaces. noted. π
linenum($str, \%opts) => STRβ adds line numbers. for example:
1|line1
2|line2
|
4|line4
known options are:
width => INT(default:4)zeropad => BOOL(default:0) β turn it on and you get something like:
0001|line1
0002|line2
|
0004|line4
skip_empty => BOOL(default:1) β if you set it to false, it keeps printing the line number even if the line is empty:
1|line1
2|line2
3|
4|line4
pad($text, $width[, $which[, $padchar[, $truncate]]]) => STRβ returns$textpadded with$padcharout to$widthcolumns.$whichis either"r"or"right"for padding on the right (this is the default if you don't specify anything),"l"or"left"for padding on the right, or"c"or"center"or"centre"for left+right padding to center the text.
bestie I am relaying this EXACTLY as written: the manpage says"l"/"left"is "for padding on the right". that's the text. I am simply the messenger. π
$padchar is whitespace if you don't specify it. it should be a string having the width of 1 column.
qqquote($str) => STRβ quotes or encodes$strinto the Perl double quote ("qq") literal representation of the string. examples, because obviously:
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. and, quoting the author's own vibe here: maybe he didn't look more closely, but he couldn't find a module that provides a function to do something like this. String::Escape, for example, provides "qqbackslash" but it does not escape "$". relatable honestly. π
None are exported by default, but they are exportable. π
π₯ SEE ALSO π₯
SHARYANTO
π HOMEPAGE π
Please visit the project's homepage at <https://metacpan.org/release/SHARYANTO-String-Util>. go, run, don't walk πββοΈπ¨
π§ SOURCE π§
Source repository is at HASH(0x353ed90).
not me reading that and going "bestie that's a stringified hash ref" β anyway, that is literally what the page says, so that is literally what you get. no cap. π«Ά
β BUGS β
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. (this is the part where you actually help, and that's the most main character energy of all π )
π AUTHOR π
Steven Haryanto <stevenharyanto@gmail.com>
π 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.
okay that's the whole page, you ate it, every function, every option, every default, every regex, every URL, all accounted for. β¨ this was SHARYA...g::Util (yes the header really truncates it like that, iconic of it), shipped as part of the User Contributed Perl Documentation, living its life at perl v5.26.1, dated 2018-04-07 β mwah, periodt, go trim something ππΈπ¦
π¦ where this page comes from
- debian bookworm: libsharyanto-string-util-perl 0.26-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libsharyanto-string-util-perl 0.26-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libsharyanto-string-util-perl 0.26-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms