in reply to Re^2: Remove redundency from an array
in thread Remove redundency from an array

Bruce and jd's solution are both fine and far less ugly than the FAQ. Is there a reason these solutions aren't on there and the FAQ version is using splice?

Replies are listed 'Best First'.
Re^4: Remove redundency from an array
by jdporter (Paladin) on Sep 24, 2007 at 14:20 UTC

    The first code block in the FAQ says:

    my %hash = map { $_, 1 } @array; # or a hash slice: @hash{ @array } = (); # or a foreach: $hash{$_} = 1 foreach ( @array );
    The first comment is my solution and the second is essentially the same as bruceb3's. Actually, I don't see where the FAQ suggests using splice for this.

Re^4: Remove redundency from an array
by dsheroh (Monsignor) on Sep 24, 2007 at 14:26 UTC
    Do you mean the Answer: page, rather than the FAQ? If so, take another look at the text preceding the code... "The answers in the FAQ don't modify the array in-place. In case that's what you need, you can do the following: The splice is needed to modify the original array in-place.