That's one of the reasons why I wrote that it depends on design decisions

For instance, a common concept in filesystems is that deleting a directory is only possible if it's empty. => rmdir

Another that deleting a directory also deletes the containing files. => rm -r

In both cases all "File" objects having weak references to the "Dir" should have been removed.

If that's done automatically in a File:: DESTROY method or only allowed to happen after a $dir->rm call are other design decisions.

The problem here is that the OP's question is to vague to be answered.

If this is all hypothetical and intended for Practice:: instead for a real simulation of a file system, I'd say the topic is too ambiguous to discuss weaken

Especially as I can't even tell that I know all subtle differences between different file systems. Hence there is no "natural" model to copy.

Update

At least, I don't know what a "directory getting deleted after going out of scope" would translate to in "normal practice" ...(?)

Personally I wouldn't allow it to happen.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery


In reply to 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
in thread Should I use weaken on an object attribute containing a reference to an object which contains reference back to original object? by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.