Subject: | use constant breaks import, perl 5.10.1 |
Date: | Mon, 8 Feb 2010 16:00:22 +0000 |
To: | bug-Sub-WrapPackages [...] rt.cpan.org |
From: | Lee Johnson <lee.johnson [...] netbanx.com> |
The module wraps any use of 'use constant' from calling packages as this
is imported as a subroutine into the callers namespace by constant. This
breaks in perl 5.10.1 as the optimiser changes the code ref to a scalar
ref:
Compare 5.8.8 (--> is debug):
-->currencyconfig,*core_code::currencyconfig
at /usr/lib/perl5/site_perl/5.8.8/Sub/WrapPackages.pm line 137.
To 5.10.1:
-->currencyconfig,SCALAR(0x956d218)
at /usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm line 137.
Not a subroutine reference
at /usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm line 139.
BEGIN failed--compilation aborted at
Patch is as follows:
Index: /usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm
===================================================================
--- /usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm (revision
716)
+++ /usr/lib/perl5/site_perl/5.10.1/Sub/WrapPackages.pm (working
copy)
@@ -134,7 +134,7 @@
foreach my $package (@targets) {
no strict;
while(my($k, $v) = each(%{$package})) {
- push @subs, $package.$k if(defined(&{$v}));
+ push @subs, $package.$k if(ref($v) eq 'CODE' &&
defined(&{$v}));
}
}
return @subs;