The stupid question is the question not asked | |
PerlMonks |
Re: Count of element in array - autovivificationby 1nickt (Canon) |
on Feb 22, 2021 at 00:21 UTC ( [id://11128639]=note: print w/replies, xml ) | Need Help?? |
Hi, This line: is populating the array with a new element $arr[($ANS-1)] if it doesn't exist. See autovivification. I would suggest validating your input and disallowing a value greater than the number of elements in your array. Hope this helps!
The way forward always starts with a minimal test.
In Section
Seekers of Perl Wisdom
|
|