No::Wor...::String(3)

πŸ“¦
version 1.7 Β· 4 versions
, in epel 9

🌸 NAME 🌸

No::Worries::String β€” string handling without worries. also hi bestie, this is the User Contributed Perl Documentation page for No::Wor...::String(3) πŸ’…


✨ SYNOPSIS ✨

use No::Worries::String qw(*);

# format a number of bytes
printf("%s has %s\n", $path, string_bytefmt(-s $path));

# 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);

πŸ’– DESCRIPTION πŸ’–

This module eases string handling by providing convenient string manipulation functions. lowkey it's here to make your string life easier, no cap ✨


πŸŽ€ FUNCTIONS πŸŽ€

okay so this module provides the following functions β€” and heads up, none of them are exported by default, so bestie you gotta import what you need 😌

πŸ’« string_bytefmt(NUMBER[, PRECISION]) πŸ’«

returns the given NUMBER formatted as a number of bytes, with a suffix such as "kB" or "GB" πŸ’–. the default precision (i.e. number of digits after the decimal dot) is 2.

πŸ¦‹ string_escape(STRING) πŸ¦‹

returns a new string with all potentially non-printable characters escaped; this includes ASCII control characters, non-7bit ASCII and Unicode characters. so it's giving safe and readable ✨

🌸 string_plural(STRING) 🌸

assuming that STRING is an English noun, returns its plural form. simple as that πŸŽ€

🌈 string_quantify(NUMBER, STRING) 🌈

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". iconic πŸ’…

πŸ‘‘ string_table(TABLE[, OPTIONS]) πŸ‘‘

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"); possible values are "left", "center" and "right".
  • colsep β€” column separator string (default: " | ").
  • header β€” array reference of column headers (default: none).
  • headsep β€” header separator</headsep> (default: "=" or "-" for MarkDown).
  • indent β€” string to prepend to each line (default: "").
  • markdown β€” return a MarkDown compatible table.

🧚 string_trim(STRING) 🧚

returns a new string with leading and trailing spaces removed β€” bye whitespace πŸ‘‹πŸ’œ


πŸ¦‹ SEE ALSO πŸ¦‹

No::Worries.


πŸ‘‘ AUTHOR πŸ‘‘

written by Lionel Cons <http://cern.ch/lionel.cons> πŸ’–

Copyright (C) CERN 2012-2019


mwah πŸ’‹ this page is from perl v5.32.1, dated 2021-10-18, and it's the No::Wor...::String(3) manual β€” bye bestie 🫢

πŸ“¦ where this page comes from