in reply to subtract two columns from perl arrays

Hello agreen54,

As others have said, we won’t write the code for you (PerlMonks is a teaching site, not a code-writing service). But I will give you two hints on possible ways to approach this task:

  1. Use a C-style for loop to iterate over the indices of the two arrays. See perlsyn#For-Loops. Update: GrandFather (below) is of course correct, prefer a Perl-style for loop! (What was I thinking?) See perlsyn#Foreach-Loops.

  2. Look at the pairwise function in the module List::MoreUtils.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: subtract two columns from perl arrays
by GrandFather (Saint) on Nov 12, 2013 at 03:42 UTC

    A Perl style for loop to iterate over the indices is clearer and more Perlish (whatever that means) ;).

    True laziness is hard work
      ...and within that "Perl style" loop, insert the "pseudocode" you wrote above:
      "i need to subtract first row second column from array1 with first row second column from array2 and goes on for all the rows assign the difference to a variable"
      Two arrays, subtraction operation, assigning the difference to a variable. I'd say you are more than halfway towards a solution. :)