Front page | perl.perl5.porters |
Postings from September 2003
base.pm: import stuff
Thread Next
From:
Alexey Tourbin
Date:
September 27, 2003 06:43
Subject:
base.pm: import stuff
Message ID:
20030927134255.GV12987@julia.office.altlinux.ru
Hi,
Here is a sort-of-problem discovered in several CPAN modules.
The generalized pattern look like this:
-myBase-------------------------
package myBase;
use myConfig;
myConfig->new;
sub new {
print __PACKAGE__;
}
1;
--------------------------------
-myConfig-----------------------
package myConfig;
use base 'myBase';
sub new {
print __PACKAGE__;
}
1;
--------------------------------
Now here is what I get and what confuses me a bit:
$ perl -lc myBase.pm
Can't locate object method "new" via package "myConfig" at myBase.pm line 5.
Compilation failed in require at (eval 1) line 3.
...propagated at /usr/lib/perl5/base.pm line 71.
BEGIN failed--compilation aborted at myConfig.pm line 3.
Compilation failed in require at myBase.pm line 3.
BEGIN failed--compilation aborted at myBase.pm line 3.
$ perl -lc myConfig.pm
myConfig
myConfig.pm syntax OK
$ perl -MmyBase -le1
myConfig
$ perl -MmyConfig -le1
Can't locate object method "new" via package "myConfig" at myBase.pm line 5.
Compilation failed in require at (eval 1) line 3.
...propagated at /usr/lib/perl5/base.pm line 71.
BEGIN failed--compilation aborted at myConfig.pm line 3.
Compilation failed in require.
BEGIN failed--compilation aborted.
$
So failures happen in different order.
Anyway, I don't expect them at all.
I hacked base.pm then and failures apparently gone. But this hack breaks the
documented behaviour of base.pm, and I wonder if it breaks something else.
--- /usr/lib/perl5/base.pm~ 2003-09-27 17:10:44 +0400
+++ /usr/lib/perl5/base.pm 2003-09-27 17:32:19 +0400
@@ -65,6 +65,7 @@
else {
local $SIG{__DIE__} = 'IGNORE';
eval "require $base";
+ eval "import $base";
# Only ignore "Can't locate" errors from our eval require.
# Other fatal errors (syntax etc) must be reported.
die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
So I'm just interested: is this a valid perl pattern?
Thanks,
Alexey Tourbin
ALT Linux Team
Thread Next
-
base.pm: import stuff
by Alexey Tourbin