You don't say how big your arrays are, but once the data is generated, this script takes just over 3/4 of a second to index 1,000,000 items (array_1) and then to process 100,000 items (array_1) against that index; deleting 198 items from the two arrays:

#! perl -slw use strict; use Time::HiRes qw[ time ]; our $A //= 1e6; our $B //= 1e5; my @alphas = 'aaa'..'zzz'; my @numers = '0'..'9'; print "Gening data..."; my @a = map{ $alphas[ rand @alphas] . $numers[rand @numers] } 1 .. $A; my @b = map{ $alphas[ rand @alphas] . $numers[rand @numers] } 1 .. $B; my @c = 1 .. @b; print "Starting..."; my $start = time; print "Indexing..."; ## index array @a my %a; undef $a{ $_ } for @a; print "Removing..."; for my $i ( reverse 0 .. $#b ) { exists $a{ $b[ $i ] } and delete $b[$i] and delete $c[$i]; } printf "Took %.6f seconds to check %d (\@b) against %d (\@a) and remov +e %d items\n", time() - $start, $B, $A, $B - @b __END__ C:\test>962209 -A=1e6 -B=1e5 Gening data... Starting... Indexing... Removing... Took 0.771435 seconds to check 100000 (@b) against 1000000 (@a) and re +move 198 items

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


In reply to Re: Match speed of R in array procesing by BrowserUk
in thread Match speed of R in array procesing by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.