[rt-users] Answer to the Undefined subroutine Scalar::Util::Weaken problem

Keith Wessel kwessel at intenex.net
Sat Feb 19 02:11:39 EST 2005


Hi,

I saw a couple of folks in January 2005's archive asking about this
"undefined subroutine &Scalar::Util::weaken" problem.  I was lucky
enough, myself, to encounter it after RedHat decided to upgrade my Perl
last weekend and mail was broken in RT all week.

It was rumored that the problem was Scalar::Util not including weaken in
its scope by default (post from Matt Walker on January 4).  This is
actually not the case.  The weaken subroutine doesn't need to be
explicitly included -- the use statement works either way both with and
without the qw(weaken) at the end of the use statement.

The problem actually stems from a version of Scalar::Util that was
compiled against a version of Perl prior to 5.8.X.  In fact, if you're
having this problem and you do change

use Scalar::Util;

to

use Scalar::Util qw(weaken);

You'll get the error message

"Weak references are not implemented in he version of Perl at..."

in your log.

The cause of this problem is documented at:

http://perlmonks.thepen.com/424738.html

Although a primative solution, (I'm old-school at system administration)
this worked:

cd /usr/perl5 (or /usr/local/perl5 or wherever your Perl lives)
find . -type d -name Scalar -print

I tar'd up all of the directories returned by the find command for safe
keeping, then did an rm -r on the file "Util.pm" in each one of them.

Now, with a clean slate and no Scalar::Util installed, do:

perl -MCPAN -e "install Scalar::Util"

This will compile Scalar::Util against your 5.8.X version of Perl which
_does_ implement weak references.

And everything should work fine now.

Hope that helps.

-Keith




More information about the rt-users mailing list