I'm new to both perl and using regex. I need to remove the white space from a string.
I found an example but its pretty opaque to me. Is this an accurate description of whats happening?
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
# =~ : regex on variable string
# s/ : replace match with value
# ^\s+ : one or more white space characters at beginning
# // : no characters
$string =~ s/\s+$//;
# =~ : regex on variable $string
# s/ : replace match with value
# \s+$ : one or more white space characters until end of line
# // : no characters
return $string;
}