in reply to Extract Duplicates by one liner

How about:

print $_, "\n" foreach grep { $_ if $hash{$_}++; } @list

(fluff has been excluded)
--------------
It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs

Replies are listed 'Best First'.
Re^2: Extract Duplicates by one liner
by Eimi Metamorphoumai (Deacon) on Mar 04, 2005 at 15:58 UTC
    grep returns a list of values for which the code block is true. You're returning $_ if it's a duplicate, which means you'll never return duplicated false values (that is, if @list = (0, 0, "", "", "0", "0", undef, undef) you'll get nothing out of it).
Re^2: Extract Duplicates by one liner
by dmorelli (Scribe) on Mar 04, 2005 at 15:56 UTC
    Getting golfy over here, but you don't even need the $_ if part:

    @a=qw/foo bar bar baz/; print join ", ", grep { !$h{$_}++ } @a;