in reply to extracting redundant and unique items

my @array = ('11','54','23','78','54','54','78'); print join ', ', grep ++$seen{$_} == 1, @array; __output__ 11, 54, 23, 78

HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: extracting redundant and unique items
by chip (Curate) on May 14, 2003 at 16:28 UTC
    Your code is just an obfuscation of what the original post said didn't work. Of course, your code works ... but so does the original code. The question's premise is just wrong. sigh

        -- Chip Salzenberg, Free-Floating Agent of Chaos

      Your code is just an obfuscation of what the original post said didn't work
      I'd say my code is clearer as it illustrates that grep is looking for elements that it has only seen once, IMHO at least. As for the question's premise being incorrect, I should've duly noted that their code was working but their question was 'wrong' (as I've done so earlier with the same (or seemingly so) AnonyMonk) but I guess tiredness got the better of me. You post, you learn ;)
      HTH

      _________
      broquaint