perl

Removing array elements in Perl


I want to remove the entire array. Currently, I do @array = ();. Does it remove the elements and clear the memory, garbage collected?

If not, do I need to use splice()?


Solution


  • So,


    You can use splice if it's convenient.

     say for @array;
     @array = ();
    

    could be written as

     say for splice(@array);