Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 搜索某个模块以比较数组_Arrays_Perl_Comparison_Perl Module - Fatal编程技术网

Arrays 搜索某个模块以比较数组

Arrays 搜索某个模块以比较数组,arrays,perl,comparison,perl-module,Arrays,Perl,Comparison,Perl Module,是否有一个模块可以更好地做到这一点(不仅仅是更换智能匹配部件) 你可以用 您正在寻找集合差,或者可能是相对补码,示例是不明确的。任何一个都足够了 use Set::Object qw(); Set::Object ->new(qw(two four six)) ->difference(Set::Object->new(qw(one two three four))) ->members; # ('six') #!/usr/bin/env

是否有一个模块可以更好地做到这一点(不仅仅是更换智能匹配部件)

你可以用

您正在寻找集合差,或者可能是相对补码,示例是不明确的。任何一个都足够了

use Set::Object qw();
Set::Object
    ->new(qw(two four six))
    ->difference(Set::Object->new(qw(one two three four)))
    ->members;    # ('six')
#!/usr/bin/env perl
use strict;
use warnings;
use List::Compare;
my @array_all  = ( qw( one two three four ) );
my @array_part = ( qw( two four six ) );
my @temp;
my $lc = List::Compare->new('--unsorted',\@array_all,\@array_part);
@temp  = $lc->get_complement;
print "@temp\n";
use Set::Object qw();
Set::Object
    ->new(qw(two four six))
    ->difference(Set::Object->new(qw(one two three four)))
    ->members;    # ('six')