in reply to Re: Re: comparing array elements
in thread comparing array elements

At first, I thought that too. But then you were considering to use a hash.

What have you tried so far?

Abigail

Replies are listed 'Best First'.
Re: Re: comparing array elements
by Anonymous Monk on Nov 21, 2003 at 09:44 UTC
    the hash backfired! so i'm using a for loop. (little success so far) my comparison operator isn't working (both arrays contain 4- letter words) and i just need to determine which words are contained in the same position in each array.

    thanks for helping!

    for (my $i =0; $i < @forward_tets; $i++) { if ($forward_tets[$i] =~ $reverse_tets[$i]) { print "$forward_tets[$i] \t $reverse_tets[$i]\n" +; } }
      To compare two strings for equality, one uses eq, not =~ (although, if the words just contain letters, it would work too).

      Abigail

        yep, but this loop seems to be comparing every position in the first array to every position in the second, not one at a time! How can I do this?