in reply to Pass array, then clear

If you have knowledge with pointer (C/C++) it is pretty much the same in Perl.

sub clear { my ($ref) = @_; $ref = []; # now ref is made to point to new object (array) @$ref = (); # what ref points to is modified }

$ref is a pointer(reference) variable, it stores only address(so as to speak). So when $ref is assigned to point to another object, subroutine caller does not see the change. On the other hand, if you assign what $ref points to (deference), the change is reflected in caller.