更新时间:2023-02-20 22:36:18
你可以像 perlfaq4:
sub uniq {
my %seen;
grep !$seen{$_}++, @_;
}
my @array = qw(one two three two three);
my @filtered = uniq(@array);
print "@filtered\n";
输出:
one two three
如果您想使用模块,请尝试 uniq 功能code>List::MoreUtils
If you want to use a module, try the uniq
function from List::MoreUtils