my @arr1 = qw/1 3 4 5 6/; my @arr2 = qw/1 2 4 5 7 10/; my %hash2; @hash2{@arr2} = ("1") x @arr2; for (sort {$a <=> $b} @arr1){ print "$_\n" if (! defined $hash2{$_}); } #### 3 6