perl中去掉字符串中空格

Perl code use strict; use warnings; my $str=" \n aaa bbb\n "; $str=~s/^\s+|\s+$//g; print($str); ^D aaa bbb