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