in reply to How can one find out the pairwise difference and product between elements in a perl array without using a perl module?
I suggest you look at the code of a module implementing this, and then take that code.