sub intersectPlus { my( $a, $b, $c, $d ) = @_; my %a; undef @a{ @$a }; my %b; undef @b{ @$b }; push @{ exists $a{ $_ } ? $d : $c }, $_ for keys %b; push @$d, @$c; return; }