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

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?

Replies are listed 'Best First'.
Re: Re: Re: comparing array elements
by Itatsumaki (Friar) on Nov 21, 2003 at 10:07 UTC

    Why do you need two for-loops? Wouldn't one work?

    my @array1 = ('test', 'text', 'next'); my @array2 = ('text', 'test', 'next'); for (my $i=0; $i < scalar(@array1); $i++) { if ($array1[$i] eq $array2[$i]) { print "$array1[$i] matches\n"; } }
Re: comparing array elements
by Abigail-II (Bishop) on Nov 21, 2003 at 10:05 UTC
    How's that possible? You index both arrays with the same key.

    Abigail

      ok, you're right.. its not working - it thinks both arrays are the same