in reply to Subtracting Lists

Here's a solution using List::MoreUtils:
use List::MoreUtils qw(any); @diff = map { my $x = $_; (any { $x eq $_ } @badstuff) ? () : $x; } @badstuff;
Admittedly it isn't very efficient, but it was kinda fun to write.

Replies are listed 'Best First'.
Re^2: Subtracting Lists
by blazar (Canon) on Jun 02, 2008 at 17:14 UTC

    I personally believe that

    @y = map { condition($_) ? $_ : () } @x;

    is generally spelt

    @y = grep { condition($_) } @x;

    Of course, you have the condition reversed, but then a ! would do, and I doubt it would impose a considerable penalty in terms of efficience.

    --
    If you can't understand the incipit, then please check the IPB Campaign.