array合并消重除了遍历有简单的办法吗?
@a = qw ( b c );
@b = qw ( a b d );
如何创建一个@c,使得@c = qw ( a b c d)?
@b = qw ( a b d );
如何创建一个@c,使得@c = qw ( a b c d)?
作者: yakczh 发布时间: 2011-06-05
QUOTE:
@a = qw ( b c );
@b = qw ( a b d );
如何创建一个@c,使得@c = qw ( ...
yakczh 发表于 2011-06-05 12:13
@b = qw ( a b d );
如何创建一个@c,使得@c = qw ( ...
yakczh 发表于 2011-06-05 12:13
@c = sort grep{!$x{$_}++} @a,@b;
作者: jason680 发布时间: 2011-06-05
use warnings;
use strict;
my %saw;
my @duplicated = ("a","a","a");
@saw{@duplicated} = ();
my @unduplicated = sort keys %saw;
print "@unduplicated\n";
达人解释一下 @saw{@duplicated} = (); 这句
use strict;
my %saw;
my @duplicated = ("a","a","a");
@saw{@duplicated} = ();
my @unduplicated = sort keys %saw;
print "@unduplicated\n";
达人解释一下 @saw{@duplicated} = (); 这句
作者: yakczh 发布时间: 2011-06-05