sub another_func { my $ref = CreateRef(); # do things with $ref return 1; # $ref goes out of scope here and so we lose our last # reference to the hash and it is freed. } sub CreateRef { my %some_hash = ('foo' => 'bar'); return \%some_hash; # We lose the 'some_hash' name reference to # the 'some_hash' data, but we have created another # reference (the return value) so the data lives... }