in reply to Re: Using Array::Diff (purpose?)
in thread Using Array::Diff

Well now that I know how to use this module I use it quite often. Mostly for managing our cisco phone server. For instance I back up the configuration file for our phone server if any changes have been applied since the last check. The output of Array:Diff is important because we forward our phone server everyday so with the added function of Array::Diff I can parse that information and skip backing it up. So it has proved to be very useful to me anyways.

Replies are listed 'Best First'.
Re^3: Using Array::Diff (sorted?)
by tye (Sage) on Dec 15, 2014 at 21:36 UTC

    Your description of how you use it sounds to me like order doesn't matter. Perhaps your arrays are always sorted so this aspect doesn't impact the end result (just impacts the efficiency of getting to the result)?

    Finding the set difference more efficiently is pretty easy:

    my @old = ...; my @new = ...; my %added; @added{@new} = (); delete @added{@old}; my @added = keys %added; # or my %is_old = map { $_ => 1 } @old; my @added = grep ! $is_old{$_}, @new;

    - tye