无法在Perl中使用接口模块

Pro*_*nda 1 perl cpan interface perl-module

我是Perl的初学者.我正在尝试使用CPAN接口模块,但我无法使其工作.我按照此页面上的说明安装了模块 .我正在使用EPIC-Eclipse.我正在尝试实现在同一网站上给出的示例.示例如下:这是Bouncable接口.

  package Bouncable;

  use Class::Interface;
  &interface;   # this actually declares the interface

  sub bounce;
  sub getBounceBack;

  1;
Run Code Online (Sandbox Code Playgroud)

这是实现Bouncable接口的Ball类.

  package Ball;

  use Class::Interface;
  &implements( 'Bouncable' );

  sub bounce {
    my $self = shift;
    print "The ball is bouncing @ ".$self->getBounceBack." strength"
  }

  sub getBounceBack {
    return 10;
  }

  1;
Run Code Online (Sandbox Code Playgroud)

代码非常简单直接.但我坚持以下错误,我无法摆脱它.

Ball tries to implement non existing interface Bouncable -- Interface Bouncable does not use the interface module. at D:/Eclipse projects/PerlTrial/Bouncable.pm line 4.
Compilation failed in require at (eval 3) line 1.
BEGIN failed--compilation aborted at (eval 3) line 1.
 at D:/Eclipse projects/PerlTrial/Ball.pm line 4.
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏!谢谢

Kee*_*yOn 6

该模块不喜欢其前面的空白区域

Bouncable.pm

use strict;
package Bouncable;

use Class::Interface;
interface;   # this actually declares the interface

sub bounce;
sub getBounceBack;

1;
Run Code Online (Sandbox Code Playgroud)

Ball.pm

use strict;
package Ball;

use Class::Interface;
implements( 'Bouncable' );

sub bounce {
    my $self = shift;
    print "The ball is bouncing @ ".$self->getBounceBack." strength"
}

sub getBounceBack {
    return 10;
}

1;
Run Code Online (Sandbox Code Playgroud)