Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Here is some code which does what you want:
use Modern::Perl; use List::Compare; # Make two arrays with fake data my @left = map {'AA' . int(rand (5000000) + 1000000)} (1 ... 5000000) +; my @right = map {'AA' . int(rand (5000000) + 1000000)} (1 ... 5000000) +; my $start = time; my $lc = List::Compare->new('-u', \@left, \@right); { open my $OUT_INTER, '>', './intersection.txt'; say $OUT_INTER $_ for $lc->get_intersection; } { open my $OUT_DIFF, '>', './difference.txt'; say $OUT_DIFF $_ for $lc->get_symmetric_difference; } my $duration = time - $start; say "Duration: $duration seconds.";
However, on my small laptop (only 2 GByte RAM and running a lot of other programs and services) I get an "Out of memory" error, so two lists of 5 million proteins is too big for it. YMMV if you have a more performant machine. It runs fine and fast for 500,000 proteins (15 seconds), 1,000,000 proteins (52 seconds) and 2,000,000 proteins (185 seconds).

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James


In reply to Re^5: Is there a way to compare strings without using an array? by CountZero
in thread Is there a way to compare strings without using an array? by Jeri

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-20 13:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found