Apr 7, 2013, 11:31 AM
The following line does not do what you expect.
It assigns zero to the first element of the array. To set an array to an empty list, use:
To set the length of an array to any non-zero value, set the last element to an arbitrary value.
Congratulations for using lexical variables. However declaring all of them at the beginning of your file largely defeats their value. You should declare each variable in the smallest possible scope. Always use strict and warnings.
Update: I have noticed another likely error. You return a zero for index if the zero-th element matches or if there is no match at all. I recommend using the last_index routine in the module List::MoreUtils. (It returns -1 for no-match)
(This post was edited by BillKSmith on Apr 7, 2013, 12:44 PM)