<?xml version="1.0" encoding="windows-1252"?>
<node id="997067" title="Re: compare arrays, and list the difference" created="2012-10-03 10:09:45" updated="2012-10-03 10:09:45">
<type id="11">
note</type>
<author id="634253">
AnomalousMonk</author>
<data>
<field name="doctext">
&lt;p&gt;
Yet another approach, not necessarily better:
&lt;/P&gt;

&lt;c&gt;
&gt;perl -wMstrict -le
"use List::MoreUtils qw(part);
 use Data::Dump qw(pp);
 ;;
 my @source = (1, 2, 3, 4, 5, 7);
 my @target = (0, 1, 3, 4, 6);
 ;;
 my %diff;
 ++$diff{$_} for @source;
 --$diff{$_} for @target;
 ;;
 my ($ar_in_t_not_s, undef, $ar_in_s_not_t) =
   part { 1 + $diff{$_} } keys %diff;
 ;;
 print 'in t not s: ', pp $ar_in_t_not_s;
 print 'in s not t: ', pp $ar_in_s_not_t;
"
in t not s: [6, 0]
in s not t: [7, 2, 5]
&lt;/C&gt;
</field>
<field name="root_node">
997024</field>
<field name="parent_node">
997024</field>
</data>
</node>
