下面是一个最小化的示例,其中我有OA.pm
(父对象)、OB.pm
子对象和运行脚本:
对象 OB:
package OB;
use OA;
require Exporter;
@ISA = (Exporter, OA);
@EXPORT = ();
sub new {
my $class = shift;
print $class->SUPER;
bless {}, $class;
};
1;
对象 OA:
package OA;
require Exporter;
@ISA = (Exporter);
@EXPORT = ();
sub new {
bless {}, shift;
};
1;
和跑步者:
#!/usr/bin/perl
use strict;
use warnings;
use OB;
print OB->new;
当我运行它时,我得到:
Can't locate object method "SUPER" via package "OB" at OB.pm line 10.
1) 可能有什么问题?
2) 如果我有多个父母,SUPER 会指出什么?
3) 是use OA
强制性的吗?