Mailing List Archive

Reference counting bug in hash ties?
The following looks like a bug to me:
If I do
perl test.pl
(v. 5.001m) on the script below I get

See me, touch me
Destroying!

which means that the object tied to %D is destroyed later than the
untie (the more complete file which was the origin of this seems to
indicate that it is destroyed only at exit). If I do
perl -x test.pl
I get

Destroying!
See me, touch me

which is what I expected.

Speaking of hash ties, I noticed that EXISTS is not defined for
in the NDBM_File package. Is there any technical reasons for this or
is just because no-one's gotten around to it?

I haven't taken the plunge (yet) to subscribe to this list so I would
appreciate if any responses were CC'd to me.

Torsten
teke@matematik.su.se


------------------------- test.pl -----------------------------
$bug++;
#!perl

use TieHash;

package Test;
@ISA = qw(TieHash::Std);

sub DESTROY { print "Destroying!\n" }

package main;

tie %D,Test;

if ($bug)
{
%D = ( 'g' => 1233 ); ### Bug
}
else
{
%D = (); $D{'g'} = 1233; ### Works
}


untie %D;
print "See me, touch me\n";