in reply to Re: Re: Arrays
in thread Comparing Two Arrays

... or even:
@array3 = keys %{{ map {$_ =>1} @array1, @array2 }};
- danboo

Replies are listed 'Best First'.
Re: Re: Re: Re: Arrays
by rje (Deacon) on Dec 08, 2001 at 01:11 UTC
    Oooooh!

    The force is strong in that one.

    Rob

Re: Re: Re: Re: Arrays
by Anonymous Monk on Dec 08, 2001 at 14:37 UTC
    @array3 = keys %{{ map {$_ =>1} @array1, @array2 }};

    I see no need for a map here:

    my @union = keys %{{(@array1,@array2)x2}};
      AM said:
      I see no need for a map here:
      my @union = keys %{{(@array1,@array2)x2}};
      That doesn't work when (@array1+@array2) is even (unless you don't mind losing some of your data :)
      my @array1=qw(a b); my @array2=qw(c d); my @union = keys %{{(@array1,@array2)x2}}; print "$_\n" for @union; #prints: a c