Name

Trim - Trim various things by removing leading and trailing whitespace

Synopsis

Trim nested structures in situ referenced from $_:

{$_ = [" a ", " b ", {" c " => {" d\n ", " e "}}];
 trim;
 is_deeply $_, ["a", "b", { c => { d => "e" } }];
}

Trim nested structures in situ:

{my $a = [" a ", " b ", {" c " => {" d\n ", " e "}}];
 trim $a;
 is_deeply $a, ["a", "b", { c => { d => "e" } }];
}

Trim cloned nested structures:

{my $a = [" a ", " b ", {" c " => {" d\n ", " e "}}];
 my $b = trim $a;
 is_deeply $b, ["a", "b", { c => { d => "e" } }];
}

Description

Trim various things by removing leading and trailing whitespace

Version "20210401".

The following sections describe the methods in each functional area of this module. For an alphabetic listing of all methods by name see Index.

Trim

Trim strings, arrays, hashes in situ and clones thereof.

trim(@things)

Trim somethings.

   Parameter  Description
1  @things    Things to be trimmed

Example:

  $_ = [" a ", " b ", {" c " => {" d ", " e "}}];                               # Trim nested structures in situ referenced from $_

  trim;  # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲

  is_deeply $_, ["a", "b", { c => { d => "e" } }];
}

{my $a = [" a ", " b ", {" c " => {" d ", " e "}}];                             # Trim nested structures in situ

 trim $a;  # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲

 is_deeply $a, ["a", "b", { c => { d => "e" } }];
}

{my $a = [" a ", " b ", {" c " => {" d ", " e "}}];                             # Trim cloned nested structures

 my $b = trim $a;  # 𝗘𝘅𝗮𝗺𝗽𝗹𝗲

 is_deeply $b, ["a", "b", { c => { d => "e" } }];

Index

1 trim - Trim somethings.

Installation

This module is written in 100% Pure Perl and, thus, it is easy to read, comprehend, use, modify and install via cpan:

sudo cpan install Trim

Author

philiprbrenan@gmail.com

http://www.appaapps.com

Copyright

Copyright (c) 2016-2021 Philip R Brenan.

This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.