# class String
package String;

use strict;
use warnings;

use Exporter;

use vars qw/@ISA @EXPORT @EXPORT_OK/;
@EXPORT_OK = ();
@EXPORT = qw/trim ltrim rtrim remove_linebreaks remove_spaces/;
@ISA = qw/Exporter/;

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

##
# Remove linebreaks
##
sub remove_linebreaks {
        my $string = shift;
        $string =~ s/\n//g;
        return $string;
}

##
# Remove emptyspaces and tabs
##
sub remove_spaces {
        my $string = shift;
        $string =~ s/ //g;
        $string =~ s/\t//g;
        return $string;
}

1;

