use strict; my @report = qw(sqltable mike_test sarak_mike); my @file = (@report, qw(plus a little more)); # off by 0 print '@file was off by ' . simple_compare(\@report,\@file) . " elements\n"; # still 0, that elem wasn't in @report pop @file; print '@file was off by ' . simple_compare(\@report,\@file) . " elements\n"; # off by 1, that one was shift @file; print '@file was off by ' . simple_compare(\@report,\@file) . " elements\n"; # returns number of elements in A that aren't in B sub simple_compare { my ($A,$B) = @_; # build lookup table my %seen = map { $_ => 1 } @$B; # find those in A that aren't in B my @aonly; foreach my $item (@$A) { push @aonly,$item unless ($seen{$item}); } return scalar @aonly; } #### my @report = qw(one one two); my @file = qw(one two two);