Hi! The code below is in working order, but it is a simpler version of what I'm actually working with. My question to you is, "What method of comparison is the fastest and least straining on memory if each of the strings were at least 1,000 unique values in length?"
I don't think using two arrays would be the most efficient use of my memory nor a hash, but I'm running out of options. Are there any better ideas?
Thanks!
#!usr/bin/perl5.8.8
use strict;
use warnings;
my @line1 = qw(C A B G F E);
my @line2 = qw(D B F);
#assume line 2 is always equal in size or smaller
foreach my $i (@line2)
{
foreach my $j (@line1)
{
if ($i eq $j) {print "$i\n";}
}
}
The reason this is of concern is because, I'm going to have to do this type of comparison at least 10,000 time (I'm estimating) per file.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.