Friday, May 4

Problem with Data-Diff

I love Data::Dump. It's my version of noSQL. I can see the data using a text editor and $data = do($filename) to load the data structure into $data.

I have a large data structure/file that has an array of hashes in it. I manage version of the file with git. I want to be able to see what change from version to version of this structure/file. Basic file comparison tools work on the file, but I want to compare the data structures in Perl. I thought the Data::Diff module would do what I want. The problem is that Data::Diff doesn't notice re-ordering items in an array!
For example:

use warnings;
use strict;
use Test::More tests => 1;
use Data::Diff qw(Diff);

is_deeply( Diff( [1,2], [1,2] ),
           Diff( [1,2], [2,1] ),
           "Should fail: 1st does not reorder elemnts, 2nd does." );

So, I'm working on my own data structure comparison module.

I want tidier difference structures. I want to be able to patch, invert patches and combine patches. We'll see if it works out.