while( @data > 1 ){ my $i = shift @data; my $o = shift @data; printf "%d %d %d\n", $i->[0] - $o->[0], $i->[2] , $o->[2]; }