The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

No::Worries::String - string handling without worries

SYNOPSIS

  use No::Worries::String qw(string_escape string_table string_trim);

  # escape a string
  printf("found %s\n", string_escape($data));

  # 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.

FUNCTIONS

This module provides the following functions (none of them being exported by default):

string_escape(STRING)

return a new string with all potentially non-printable characters escaped; this includes ASCII control characters, non-7bit ASCII and Unicode characters

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:

  • colsep: column separator string (default: " | ")

  • header: array reference of column headers (default: none)

  • headsep: header separator (default: "=")

  • indent: string to prepend to each line (default: "")

string_trim(STRING)

return a new string with leading and trailing spaces removed

SEE ALSO

No::Worries.

AUTHOR

Lionel Cons http://cern.ch/lionel.cons

Copyright (C) CERN 2012-2013