Banal-Utils
view release on metacpan or search on metacpan
lib/Banal/Utils/String.pm view on Meta::CPAN
use strict;
use warnings;
no warnings qw(uninitialized);
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(trim ltrim rtrim);
# Perl trim function to remove whitespace from the start and end of the string
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
# Left trim function to remove leading whitespace
sub ltrim($)
{
my $string = shift;
$string =~ s/^\s+//;
return $string;
}
# Right trim function to remove trailing whitespace
sub rtrim($)
{
my $string = shift;
$string =~ s/\s+$//;
return $string;
}
1;
__END__
( run in 0.689 second using v1.01-cache-2.11-cpan-65fba6d93b7 )