in reply to Check if one array is a subset of another
If, as suggested by your sample code & data, your array elements contain no spaces, then a very simple, and relatively efficient mechanism would be:
@bigarray = qw(this is the main array from which to delete elements);; @smallarray = qw(delete elements);; ($temp = "@bigarray") =~ s[@smallarray][] and @bigarray = split ' ', +$temp;; print for @bigarray;; this is the main array from which to
If your elements can contain spaces, then the same technique could be utilised, by using a different separator char -- eg. $;. It is only slightly more complex;
@bigarray = qw(this is the main array from which to delete elements);; @smallarray = qw(delete elements);; $b = join $;, @bigarray;; $s = join $;, @smallarray;; $b =~ s[$s][] and @bigarray = split $;, $b;; print for @bigarray;; this is the main array from which to
|
|---|