&gt; You call Perl 5&#x27;s use of reference counting &quot;undefined behavior&quot;?<p>No, I call counting on the fact that items with no references will be reclaimed (triggering DESTROY) <i>immediately</i> when they go out of scope undefined behavior.  The fact that it happens very fast in most cases because it&#x27;s reference counted and not garbage collected is not something that should be counted on.  In fact, I&#x27;m pretty sure there are cases where in very tight loops, DESTROY isn&#x27;t called immediately on scope end.  I vaguely recall having to deal with that problem (but it could just as likely been a bug of mine that appeared to indicate that until I found it).