in reply to Re: Fast way - get array elements > 4 chars
in thread Fast way - get array elements > 4 chars

Update: Nevermind, that was your intention. Sorry, I guess I didn't read your whole post.

The latter doesn't work. You seem to be expecting lazy evaluation, but map processes the entire list before grep is called.

$ perl -le'print grep { $seen{$_} == 1 } map { $seen{$_}++; $_ } qw( a + b a c );' bc

Fix:

grep { ++$seen{$_} == 1 } grep { !$seen{$_}++ }