Skip to content

Instantly share code, notes, and snippets.

@chrisa
Created October 27, 2009 19:33
Show Gist options
  • Save chrisa/219874 to your computer and use it in GitHub Desktop.
Save chrisa/219874 to your computer and use it in GitHub Desktop.
# System - Centos 5, RPM perl:
perl-5.8.8-18.el5_3.1
# OK:
[chris@dev ~]$ /usr/bin/perl -MScalar::Util=weaken -e1
[chris@dev ~]$
# same, but local::libbed, self-contained:
[chris@dev ~]$ cat test.pl
use local::lib '--self-contained';
use Scalar::Util qw/ weaken /;
# three perls on this box, first the system perl:
[chris@dev ~]$ perl -v
This is perl, v5.8.8 built for i386-linux-thread-multi
[chris@dev ~]$ which perl
/usr/bin/perl
# local 5.8.8:
[chris@dev ~]$ /opt/perl-5.8.8/bin/perl -v
This is perl, v5.8.8 built for i686-linux-thread-multi
# local 5.10.0:
[chris@dev ~]$ /opt/perl-5.10.0/bin/perl -v
This is perl, v5.10.0 built for i686-linux
# same local::lib version in each:
[chris@dev ~]$ /usr/bin/perl -Mlocal::lib -e 'print "$local::lib::VERSION\n"'
1.004008
[chris@dev ~]$ /opt/perl-5.8.8/bin/perl -Mlocal::lib -e 'print "$local::lib::VERSION\n"'
1.004008
[chris@dev ~]$ /opt/perl-5.10.0/bin/perl -Mlocal::lib -e 'print "$local::lib::VERSION\n"'
1.004008
# WTF:
[chris@dev ~]$ /usr/bin/perl test.pl
Use of uninitialized value in split at /usr/lib/perl5/site_perl/5.8.8/local/lib.pm line 57.
Weak references are not implemented in the version of perl at test.pl line 2
BEGIN failed--compilation aborted at test.pl line 2.
[chris@dev ~]$ /opt/perl-5.8.8/bin/perl test.pl
Use of uninitialized value in split at /opt/perl-5.8.8/lib/site_perl/5.8.8/local/lib.pm line 57.
[chris@dev ~]$ /opt/perl-5.10.0/bin/perl test.pl
Use of uninitialized value $perl5lib in split at /opt/perl-5.10.0/lib/site_perl/5.10.0/local/lib.pm line 57.
the explanation:
RedHat's stock Scalar::Util is broken, and believes its perl doesn't support weakrefs.
I also have a fixed Scalar::Util installed in core:
[chris@dev ~]$ find /usr/lib/perl5/ | grep Scalar/Util.pm
/usr/lib/perl5/5.8.8/Scalar/Util.pm
/usr/lib/perl5/5.8.8/i386-linux-thread-multi/Scalar/Util.pm
local::lib --self-contained is affecting which of those gets loaded first, despite them
both being "core" modules:
# without local::lib --self-contained:
[chris@dev ~]$ strace -e open /usr/bin/perl -MScalar::Util=weaken -e1 2>&1 | grep Scalar
open("/usr/lib/perl5/5.8.8/i386-linux-thread-multi/Scalar/Util.pm", O_RDONLY|O_LARGEFILE) = 4
# with:
[chris@dev ~]$ strace -e open /usr/bin/perl test.pl 2>&1 | grep Scalar
open("/usr/lib/perl5/5.8.8/Scalar/Util.pm", O_RDONLY|O_LARGEFILE) = 4
bug that the order of @INC paths gets reversed? don't-do-that-then? just load Scalar::Util before local::lib --self-contained?
# before:
$VAR1 = {
'inc' => [
'/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi',
'/usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi',
'/usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi',
'/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi',
'/usr/lib/perl5/site_perl/5.8.8',
'/usr/lib/perl5/site_perl/5.8.7',
'/usr/lib/perl5/site_perl/5.8.6',
'/usr/lib/perl5/site_perl/5.8.5',
'/usr/lib/perl5/site_perl',
'/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi',
'/usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi',
'/usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi',
'/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi',
'/usr/lib/perl5/vendor_perl/5.8.8',
'/usr/lib/perl5/vendor_perl/5.8.7',
'/usr/lib/perl5/vendor_perl/5.8.6',
'/usr/lib/perl5/vendor_perl/5.8.5',
'/usr/lib/perl5/vendor_perl',
'/usr/lib/perl5/5.8.8/i386-linux-thread-multi',
'/usr/lib/perl5/5.8.8',
'.'
]
};
# after
$VAR1 = {
'inc' => [
'/home/chris/perl5/lib/perl5',
'/home/chris/perl5/lib/perl5/i386-linux-thread-multi',
'/lib/perl5',
'/lib/perl5/i386-linux-thread-multi',
'/usr/lib/perl5/5.8.8',
'/usr/lib/perl5/5.8.8/i386-linux-thread-multi'
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment