Hire a Developer for Related Work / Installation | $55 hr
Rating: | Rate It:
Average Votes: (3443)
Favorites:
Code and explanation of a Trim function for the Perl Programming language.
There is a simple function you can build to trim strings in your Perl programs.
The function uses two regular expressions to trim a string from the left side of the string as well as one for the right side.
Code Snippet 1
#!/usr/bin/perl -w
# Perl trim function
sub trimStr($){
my $string = shift;
# the first regular expression removes space
# from the left side
$string =~ s/^\s+//;
# the second regular expression removes space
# from the right side
$string =~ s/\s+$//;