Ami*_*and 1 perl grep dictionary
我想使用 map 或 grep 将数组 @x 转换为数组 @y。
@x = ('aa','', 'bb',' ','cc', "\t");
@y = ('aa','bb','cc');
Run Code Online (Sandbox Code Playgroud)
我试过的:
#@x= grep {s/^\s+|\s+$//g} @x; # not correct
@y = grep { $_ } @x; # remove '' null character
Run Code Online (Sandbox Code Playgroud)
请建议更好的方法来做到这一点,最好在一行中。