use Test::More tests => 2; sub deleteref { my $h = shift; undef $h; } my $c = {d => 3}; deleteref($c); is( keys %$c, 1, 'undef on copy of hashref in a subroutine should not clear it' ); undef $c; is( keys %$c, 0, 'undef on hash reference, not a copy of it in a subroutine, should clear it' );