[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: [ID 20000124.001] Refcount problem



On Tue, Jan 25, 2000 at 02:56:12PM -0700, Tom Christiansen wrote:
> >local(*FOO) has always localized the contents of *FOO (the GvGP in
> >gutspeech).  In fact, this is the behavior that makes local(*FOO)
> >also localize $FOO, %FOO, @FOO and the filehandle FOO.
> 
> I believe that the standard way to deal with this has been to use
> *FH not \*FH.

I don't know where I picked up the habit of using \*FH (I distinctly
remember reading it *somewhere* in the docs, but I've been unable to
find where that was.)  The problem is that the reference from \*FH
works at all.  If printing to \*FH hadn't worked, then the rest of the
problem would never appear - but as it is, this can cause subtle bugs.

When I discovered this, I thought I was returning a locked filehandle,
which was supposed to expire when the variable it was assigned to in
the calling function went out of scope (with a "honourary close()" in
order to make sure optimization didn't get rid of it early -
unchecked, as nothing could be done if it failed.)  This was supposed
to act as a mutex to serialize multiple copies of the program in
question, but actually no longer did.

> Notice how the examples in perldata on returning local handles do
> not use backslash.

This is the solution I used to work around the problem once I
identified exactly where the problem came from.

Eivind.


References to:
Tom Christiansen <tchrist@chthon.perl.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]