Assinging to $_ without localizing it is dangerous.
(local $_ = $before) =~ s/^\s+|\s+$//g;
or
(my $after = $before) =~ s/^\s+|\s+$//g;
should be used in just almost all cicumstances.
In reply to Re^2: what is the function should I need to use for trim white spaces ?
by ikegami
in thread what is the function should I need to use for trim white spaces ?
by jesuashok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |