CC: | slaven [...] rezic.de |
Subject: | [PATCH] Avoid deprecated use of tied() |
Date: | Sun, 3 Apr 2011 16:57:33 -0700 |
To: | bug-XML-Parser [...] rt.cpan.org |
From: | Father Chrysostomos <sprout [...] cpan.org> |
In Perl 5.14, which is soon to be released, using tied($handle) is deprecated. This is because tied($foo) is supposed to act on $foo as a scalar, without regard to whatever value it might hold. (It will be changed to work this way in 5.16.)
An explicit * will avoid the warning: tied(*$handle).
Here is a patch to fix this. It requires a little explanation:
I was going simply to change tied($arg) to eval { tied(*$arg) }, when I realised that this check is unnecessary as of 5.8.0, in which the tiedness of the handle is attached to the IO thingy itself, not to the glob.
Then I also realised that the existing logic for testing for a tied handle is faulty and can’t possibly have worked: If tied($arg) returns true and the scalar $arg is not tied, then it can only be a glob, for which ref($arg) returns an empty string. So the ‘if defined &{"${class}::TIEHANDLE"}’ check looks in the main package for a TIEHANDLE subroutine. The rest of the code expects to call methods on the file handle. I do not believe that is possible in 5.6, so this patch simply removes that elsif().
Message body is not shown because sender requested not to inline it.