This is potentially a tough one to solve without the data, and the subroutine. Are their duplicate lines in your data? What's $index doing in your script? I don't see it being used anywhere in the code you've posted.
A main worry here is that you may not have the right kind of data structure: you've got three arrays, but I'm not sure about how the data in them are related. You loop over one array, and pass elements from different arrays to the subroutine. Could you perhaps say more about your data structure (e.g. what data is contained within a single record) ? I would guess, from your description, that an array of array references (which is how one implements a two-dimensional array in Perl) would help to solve your problem.
an aside concerning that $index variable : foreach is actually a synonym of for as far as Perl is concerned, but you seem to be mixing up the two ways of using them to iterate over an array (by iterating over the indices of the array, or by iterating -- sans index -- over the array)
Philosophy can be made out of anything. Or less -- Jerry A. Fodor
In reply to Re: Foreach Complications
by arturo
in thread Foreach Complications
by ImpalaSS
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |