if I delete the Dir, the Files can no longer reference the Dir
It's not only a question of deletion. The reference to Dir within File will disappear as soon as the Dir object gets out of scope, which is a Bad Thing™
use strict; use warnings; use Data::Dump; my $file = Practice::File->new('foo'); { my $dir = Practice::Dir->new('bar'); $file->add_dir($dir); } dd $file; __DATA__ bless({ dir => undef, name => "foo" }, "Practice::File")
Greetings,
-jo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Should I use weaken on an object attribute containing a reference to an object which contains reference back to original object?
by LanX (Saint) on Jan 21, 2024 at 23:06 UTC |