| 1 | #=============================================== | ||
| 2 | package Banal::Utils::String; | ||
| 3 | |||
| 4 | 2 | ▶ | use 5.006; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 2 | ▶ | no warnings qw(uninitialized); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 2 | require Exporter; | |
| 11 | |||
| 12 | 2 | our @ISA = qw(Exporter); | |
| 13 | 2 | our @EXPORT_OK = qw(trim ltrim rtrim); | |
| 14 | |||
| 15 | # Perl trim function to remove whitespace from the start and end of the string | ||
| 16 | sub trim($) | ||
| 17 | 0 | ▶ | { |
|
Subroutine
trim: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 18 | 0 | my $string = shift; | |
| 19 | 0 | $string =~ s/^\s+//; | |
| 20 | 0 | $string =~ s/\s+$//; | |
| 21 | 0 | return $string; | |
| 22 | } | ||
| 23 | # Left trim function to remove leading whitespace | ||
| 24 | sub ltrim($) | ||
| 25 | 0 | ▶ | { |
|
Subroutine
ltrim: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 26 | 0 | my $string = shift; | |
| 27 | 0 | $string =~ s/^\s+//; | |
| 28 | 0 | return $string; | |
| 29 | } | ||
| 30 | # Right trim function to remove trailing whitespace | ||
| 31 | sub rtrim($) | ||
| 32 | 0 | ▶ | { |
|
Subroutine
rtrim: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 33 | 0 | my $string = shift; | |
| 34 | 0 | $string =~ s/\s+$//; | |
| 35 | 0 | return $string; | |
| 36 | } | ||
| 37 | |||
| 38 | 2 | 1; | |
| 39 | |||
| 40 | __END__ | ||