in reply to A better way than ||
I guess you must be in a part of the world that is already in 2006, so Happy New Year to you as well!
As you said, the two arrays have the same number of elements, so if you are just accessing all of the elements of each array in turn, there is no reason why you should be accessing uninitialized elements. The problem is this:
That for loop will count one past the last element in the array, because the scalar value of @weights is the number of elements in the array, not the index of the last element. You should change this to:for (0..@weights)
To be really, really sure, you could do this:for (0..$#weights)
To go from the first element to the last element, but in sane code, $[ is always supposed to be 0 anyway, so I wouldn't bother with it.for ($[..$#weights)
|
|---|