## Trim function.
my $string = shift;
$string =~ s/^\s+|\s+$//g;
print "[".trim(" My name is Deadman ")."]\n";
Friday, February 15, 2008
Perl: Trim a string
There are many ways to trim a string in perl. Below is one of them. I used a simple regular expression that just removes the whitespaces from begin and end of the string.
This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...
Many other programming languages, Python does have the comparator facility to sort a list according to your need. You can define a customize...
Actually there is no specific variable existence like string, integer, etc at Perl. All are called Scalar, and it takes all at the same time...