$ perl -le' use List::MoreUtils q=pairwise=; # corrected, see comment below my @a = ( 1, 2, 4, 5, 3 ); my @b = ( 1, 2, 4, 2, 3 ); my @c = pairwise { $a == $b ? 1 : 0 } @a, @b; print "@c"; ' 1 1 1 0 1