Compare 2 arrays

From: aYaX (none_at_none.xxx)
Date: 05/29/04


Date: Sat, 29 May 2004 20:19:23 +0200

hello :)

I need to compare 2 arrays and get results:
number record with 1 from arrayA/and results coincident from arrayB

(excluding key [0])

example:
6/5

(example)
arrays contains only 0 and 1:
arrayA:

( [0] => 2 [1] => 1 [2] => 0 [3] => 0 [4] => 1 [5] => 0 [6] => 0 [7] => 1
[8] => 0 [9] => 1 [10] => 0 [11] => 0 [12] => 0 [13] => 1 [14] => 0 [15] =>
0 [16] => 1 [17] => 1 [18] => 1 [19] => 1 [20] => 1 [21] => 0 [22] => 0 )

arrayB:

( [0] => 9 [1] => 1 [2] => 1 [3] => 1 [4] => 0 [5] => 0 [6] => 0 [7] => 0
[8] => 1 [9] => 0 [10] => 1 [11] => 0 [12] => 0 [13] => 0 [14] => 0 [15] =>
0 [16] => 0 [17] => 0 [18] => 0 [19] => 0 [20] => 0 [21] => 0 [22] => 0 )

Thanks and sorry for my english



Relevant Pages

  • Re: finding matches in multiple arrays
    ... I assume you mean to find all values that appear in both arrays? ... for each element in @arrayA look through all the ... elements in @arrayB to see if there's a matching value. ... foreach my $inA { ...
    (perl.beginners)
  • Re: Matching paired arrays into hash
    ... I was wondering if there is an efficient method in perl for joining ... two arrays of equal length (@arrayA and @arrayB) ...
    (comp.lang.perl.misc)