http://www.perlmonks.org?node_id=144318

webadept has asked for the wisdom of the Perl Monks concerning the following question:

I recently wrote program that reused an array variable several times. Normally I clear the values of any array by : $#myarray=(); and have never had a problem with this, of course I never really needed to make sure that the @myarray[0] cell was free. This program developed a bug because the [0] vaule continued to hold on even though I reset the variable with the above method.

To solve this I used $#array= -1; and that solved the problem with no more bugs. I needed asprin from pounding my head on the desk, but the program worked and that's what's important.

I've checked many sources and all of them give my first method as the proper means of clearing an array of all values. I'm just wondering if anyone else has had issues with this, or hopfully to save someone else the headache of my little discovery

webadept

Edit by tye