Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the problem is in the Perl code, you might have a reference that points to itself, or a parent node.</p> <p>Usually it comes in the form of an object, that reference a parent object.</p> <pre><code>{ package parent; sub new{ bless { 'name' =&gt; $_[1] }, $_[0] } sub add_child{ my($self,$child_name) = @_; my $child = child-&gt;new($child_name,$self); $self-&gt;{$child_name} = $child; # saves a reference to the child return $child; } } { package child; sub new{ my($class,$name,$parent) = @_; my $self = bless { 'name' =&gt; $name, 'parent' =&gt; $parent # saves a reference to the parent }, $class; return $self; } } { my $parent = parent-&gt;new('Dad'); my $child = parent-&gt;add_child('Son'); # At this point both of these are true # $parent-&gt;{Son}{parent} == $parent # $child-&gt;{parent}{Son} == $child # Both of the objects **would** be destroyed upon leaving # the current scope, except that the object is self-referential } # Both objects still exist here, but there is no way to access either of them. </code></pre> <p>The best way to fix this is to use <a href="http://search.cpan.org/perldoc/Scalar::Util#weaken" rel="noreferrer">Scalar::Util::weaken</a>.</p> <pre><code>use Scalar::Util qw'weaken'; { package child; sub new{ my($class,$name,$parent) = @_; my $self = bless { 'name' =&gt; $name, 'parent' =&gt; $parent }, $class; weaken ${$self-&gt;{parent}}; return $self; } } </code></pre> <p>I would recommend dropping the reference to the parent object, from the child, if at all possible.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload