in reply to Re: sum of integers in a column
in thread sum of integers in a column

Shouldn't that be:  $sum[$_] += $column[$_] for 0..$#column;

I presume the $i should actually be the default index variable $_ generated by the for loop?

Replies are listed 'Best First'.
Re^3: sum of integers in a column
by muba (Priest) on Oct 12, 2010 at 12:41 UTC

    You're quite right. Initially I wrote it with a for my $i (...) {...} loop but then thought I could do it with a postfix for. Forgot to replace that one instance of $i with $_. Corrected. Thank you :)

      Luckily using strict and warnings would have highlighted the typo :)
      - - for failure to add the pragmas you advocated -- which would have shown you that your correction is still incorrect.