in reply to Re: what is the function should I need to use for trim white spaces ?
in thread what is the function should I need to use for trim white spaces ?

($_ = $before) =~ s/^\s+|\s+$//g;

Just as a minor nitpick I'd localise $_, but then I wouldn't bind with =~, I'd just

local $_ = $before; s/^\s+|\s+$//g;

or else

(my $after = $before) =~ s/^\s+|\s+$//g;