in reply to WHAT IS WRONG TO PASS PARAMETER TO THE ARRAY?

If you use warnings, you'd also get a clue that line 5 isn't what you want from something like
"my" variable @partofcookie masks earlier declaration in same scope at ...