in reply to Array compare not matching all elements
Hi, the classic technique is to put the elements of one array into a hash and see if the elements of the other array have keys in the hash.
Update: Here's an example, with some points to consider:
use strict; use warnings; use feature 'say'; my @array1 = ("A2","A5","C1","G0","T3","T4"); my @array2 = ("A2","A3","A5","G1","G0","G4"); my %lookup = map { $_ => 1 } @array1; for my $thing ( @array2 ) { say "I found $thing" if $lookup{ $thing }; } __END__
Hope this helps!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Array compare not matching all elements
by Dnamonk3 (Novice) on Oct 29, 2018 at 14:31 UTC |