use strict;
use warnings;
use feature 'say';
use Scalar::Util qw(weaken);
# a parent/child cycle would leak memory
my $parent = { name => "p" };
my $child = { name => "c" };
$parent->{child} = $child;
$child->{parent} = $parent;
# weaken the back-reference so the cycle can be freed
weaken($child->{parent});
say $child->{parent}{name};Scalar::Util weaken avoids leaks