my @array1 = ('aa', 'bb');my @array2 = ('cc', 'aa');怎样得到 @array3 = ('aa', 'bb', 'cc') ???
2 回答
神不在的星期二
TA贡献1963条经验 获得超6个赞
my @array1 = ('aa', 'bb');
my @array2 = ('cc', 'aa');
@array3 = (@array1, @array2);
my %count;
my @array3_new = grep { ++$count{ $_ } < 2; } @array3;
print @array3_new;
或者
@array3 = (@array1, @array2);
foreach my $item ( @array3 ){
if ( ! grep( /$item/, @array3_new ) ){
push( @array3_new, $item );}}
print @array3_new;
- 2 回答
- 0 关注
- 1426 浏览
添加回答
举报
0/150
提交
取消