in reply to Pass array, then clear

When you write:
my($data) = @_;
you're creating a new variable that happens to contain an array ref defined in the caller. Then you simply give another value (namely a reference to an empty array) to that variable. There should not be any reason why this would modify the original array ref.

Just as if you say:

my $c = 5; my $d = $c; $d = 6;
this will not change the value of $c.

In the commented out version, something else is happening: @$data is actually the array referred to by $data, so you are not modifying the local variable just created in the sub, but the value (the anonymous array referred to by the array ref) $data refers to.