in reply to Comparing each element of Array A to Array B

Here's the canonical WTDI:

#!/perl/bin/perl use strict; use warnings; my @arrA = qw/ 1 3 5 7 9 11 13 /; my @arrB = qw/ 1 4 9 16 25 /; my %hashB = map { $_ => 1 } @arrB; # Hashify the B array for later com +parison print qq(These numbers are in array A:\n); print join(" ", @arrA); print "\n\n"; print qq(These numbers are in array B:\n); print join(" ", @arrB); print "\n\n"; print qq(These numbers are in array A, but not array B:\n); for my $curA (@arrA) { unless (exists($hashB{$curA})) { print " $curA"; } } print "\n\n";

Output:

These numbers are in array A: 1 3 5 7 9 11 13 These numbers are in array B: 1 4 9 16 25 These numbers are in array A, but not array B: 3 5 7 11 13

Where do you want *them* to go today?