replicant4 has asked for the wisdom of the Perl Monks concerning the following question:

To everyone who might be able to help. I have two arrays @site1 and @site2, each of which contain a number of elements called sites(e.g. $site1, $site2 etc.). Each site contains a string of characters.(e.g $site1 = AAADD) I want to compare each $site from @site1 to every $site is @site2 and get all combinations. That is if $site1= 'AAA' and $site2 ='BBB', then I should get AB AB AB . After that what I find I need to add it to specific counters. That is counterAB=3. Does anyone have any ideas on how to do that? Thanks in advance for your help, much appreciated.
  • Comment on pairwise comparisons between strings in arrays

Replies are listed 'Best First'.
Re: pairwise comparisons between strings in arrays
by BrowserUk (Patriarch) on Oct 19, 2004 at 19:10 UTC

    Did you see the answers you recieved the first time Comparing two arrays and counting pairwise comparisons you asked this question?


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
      Yes I did now but not before I posted it for the second time. Just to make some things clearer. I want to compare the first $site from the first @site, with all the $sites from the second @site and then move to the second $site from the first @site with all the $sites from the second @array, until I run over the whole first @array. Another thing is that I want to cobine the corresponding letters that means if $site1= 'ABCD' and $site2 = 'EFGH', then I only want the combinations 1-1, 2-2, 3-3, 4-4, that is AE, BF, CG, DH. And finally one other thing. I want to reset the counters to 0 everytime that I move from the first $site of @array1 to the second $site of @array1. I hope that this makes sence. Once again thanks for all the answers and the help .
      A reply falls below the community's threshold of quality. You may see it by logging in.