输出有点笨拙,但我喜欢这样Data::Diff
的任务:
use Data::Diff 'Diff';
use Data::Dumper;
@a = ( ["Fileset1", "1.0.2.3", "COMMITTED", "Description of file" ],
["Fileset2", "2.4.2.2", "COMMITTED", "Description of a different file" ],
["Fileset3", "1.2.3.4", "COMMITTED", "Description of a different file" ] );
@b = ( ["Fileset1", "1.0.2.3", "COMMITTED", "Description of file" ],
["Fileset2", "2.4.2.99", "COMMITTED", "Description of a different file" ] );
$out = Diff(\@a,\@b);
print Dumper($out);
结果:
$VAR1 = {
'diff' => [
{
'uniq_a' => [
'2.4.2.2'
],
'same' => [
{
'same' => 'COMMITTED',
'type' => ''
},
{
'same' => 'Description of a different file',
'type' => ''
},
{
'same' => 'Fileset2',
'type' => ''
}
],
'type' => 'ARRAY',
'uniq_b' => [
'2.4.2.99'
]
}
],
'uniq_a' => [
[
'Fileset3',
'1.2.3.4',
'COMMITTED',
'Description of a different file'
]
],
'same' => [
{
'same' => [
{
'same' => '1.0.2.3',
'type' => ''
},
{
'same' => 'COMMITTED',
'type' => ''
},
{
'same' => 'Description of file',
'type' => ''
},
{
'same' => 'Fileset1',
'type' => ''
}
],
'type' => 'ARRAY'
}
],
'type' => 'ARRAY'
};