use strict; my @array1=qw(1 2 3 4); my @array2=qw(4 3 2 1); #ascending my $i =0; while($i<= $#array1){ print $array1[$i] - $array2[$i],"\n"; $i++; }