supriyoch_2008 has asked for the wisdom of the Perl Monks concerning the following question:
Hi PerlMonks,
I have an array like @array = qw/a b c d/; I am interested to find out the pairwise difference and product between any two elements in the array by taking out each element from the array and then calculating the difference and the product as shown in the expected result. Since there are 4 elements, there will be n(n-1)/2=6 pairwise differences and products, where n=4.
#!usr/bin/perl use warnings; @array=qw/a b c d/; # Code for taking out each element: foreach $item (@array) { $each_ele=$item; print"\n Each element: $each_ele\n"; } # Code ????? ............ ............ exit;
The expected result should look like:
Difference: a-b a-c a-d b-c b-d c-d Product: a.b a.c a.d b.c b.d c.d
|
---|
Back to
Seekers of Perl Wisdom