use warnings; use strict; use Data::Dumper; my @list1; my @list2; while () { next unless /\S/; @list1 = split; if (@list2) { my @diff; for my $i (0 .. $#list1) { push @diff, ($list1[$i] - $list2[$i]); } print Dumper(\@diff); } @list2 = @list1; } __DATA__ 42.034 41.630 40.158 26.823 26.366 25.289 23.949 34.712 35.133 35.185 35.577 28.463 28.412 30.831 33.490 33.839 32.059 32.072 33.425 33.349 34.709