[Chicago-talk] Array diff

Young, Darren Darren.Young at ChicagoGSB.edu
Wed Aug 6 12:40:41 PDT 2008


Need to diff() 2 arrays, anyone used Array::Diff? Docs say it returns
added and delted arrays but the example given shows a scalar.

    my @old = ( 'a', 'b', 'c' );
    my @new = ( 'b', 'c', 'd' );
    
    my $diff = Array::Diff->diff( \@old, \@new );
    
    $diff->count   # 2
    $diff->added   # [ 'd' ];
    $diff->deleted # [ 'a' ];

So, would the added be @added = $diff::added? Am I missing something
obvious?

In my usage here, @old has 480 elements, @new has 489.


More information about the Chicago-talk mailing list