1
我有2D數組(@AoA),它包含對其他字符串數組的引用。這個@AoA的大小每次都不一樣。我想比較每個這些字符串數組。
爲字符串的第一個數組進行相互比較,我可以用這樣的:比較perl中的多個數組
for (my $i=0; $i < $#AoA; $i++) {
my $lcm = List::Compare->new($aAoA[$i], $AoA[$i+1]);
my @intersection = $lcm->get_intersection;
if (@intersection) {
#some code here
}
但如何相互比較每個數組的最佳方式? 我想結果是這樣的:
Arr1 Arr2 …. ArrN
Arr1 x 1 match 3 matches 0 matches
Arr2 x N matches 3 matches
…. x 1 match
ArrN x
如果列表進行排序,你可能可以做更有效。他們? – neuhaus
@ neuhasus不,他們沒有排序。每個列表中的元素順序包含特定的信息。 –
你可能會濫用Test :: Deep。 – simbabque