Change to: for ( 0..$#weights )
Alternatively do away with all that tedious messing around with indices completely :-)
use List::Util qw( sum ); use List::MoreUtils qw( pairwise ); my $sum = sum pairwise { $a * $b } @weights, @digits;
In reply to Re^2: A better way than ||
by adrianh
in thread A better way than ||
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |