On Jul 12, J�rg Ziefle said:
>Here's my first post to FWP. I hope it doesn't suck too much. :)
>
>@ary1 = grep { my $f = $_; !scalar grep { $_ eq $f } @ary2 } @ary1;
It's a bit more time-effective to use a hash of the elements in @ary2.
my %in_ary2;
@in_ary2{@ary2} = ();
@ary1 = grep !exists($in_ary2{$_}), @ary1;
One good reason to take this approach is because
grep { $_ == 1 } (1 .. 1_000);
goes through the entire list before returning, so even though you've found
a match, you look through the rest of the list (needlessly).
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **