【问题标题】:CPAN install module says OK but compilation fails on that moduleCPAN 安装模块显示正常,但该模块编译失败
【发布时间】:2013-03-13 10:04:53
【问题描述】:

我正在尝试按照here 的解释对MIME::Parser::FileUnder 进行子类化。所以我安装了这个模块:

$ sudo cpan install MIME::Parser::FileUnder
[...]
Result: PASS
  DSKOLL/MIME-tools-5.504.tar.gz
  /usr/bin/make test -- OK
Running make install
Manifying blib/man3/MIME::Decoder::Gzip64.3pm
Appending installation info to /usr/local/lib/perl/5.14.2/perllocal.pod
  DSKOLL/MIME-tools-5.504.tar.gz
  sudo /usr/bin/make install  -- OK

看起来安装正确,但是

$ ./test_gmail.pl
Can't locate MIME/Parser/FileUnder.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at GMailMIMEParser.pm line 4.
BEGIN failed--compilation aborted at GMailMIMEParser.pm line 4.
Compilation failed in require at ./test_gmail.pl line 13.
BEGIN failed--compilation aborted at ./test_gmail.pl line 13.

如果我再次尝试安装MIME::Parser::FileUnder,它会奇怪地安装它,而不是像任何其他模块一样告诉我它是最新的。

这是我的子类GMailMIMEParser

package GMailMIMEParser;

use strict;
use MIME::Parser::FileUnder;

our @ISA = qw(MIME::Parser::FileUnder);

my $cur = 0;

sub output_path
{
    my $class = shift;
    my $head = shift;
    print(STDERR $head);
    $cur++;
    return "./$cur";
}

提前致谢!

【问题讨论】:

  • 这是一个文件管理器子类或 MIME 解析器,所以我想你想要我的 $parser = new MIME::Parser;,然后是 $parser->filer->output_path(xxx)。
  • 我不明白你的意思。我必须按照链接中的说明对MIME::Parser::FileUnder 进行子类化,才能使用我自己的output_path()GMailMIMEParser 子类MIME::Parser::FileUnder,但它不会识别MIME::Parser::FileUnder

标签: linux perl cpan


【解决方案1】:

我只是在做错事。我必须继承 MIME::Parser::Filer 而不是 MIME::Parser::FileUnder,它本身就是 MIME::Parser::Filer 子类。

package GMailMIMEParser;

use strict;
use MIME::Parser::Filer;

our @ISA = qw(MIME::Parser::Filer);

my $cur = 0;

sub output_path
{
    my $class = shift;
    my $head = shift;
    print(STDERR $head);
    $cur++;
    return "./$cur";
}

【讨论】:

    猜你喜欢
    • 2018-06-19
    • 2013-11-04
    • 1970-01-01
    • 2012-05-04
    • 1970-01-01
    • 2015-09-16
    • 1970-01-01
    • 1970-01-01
    • 2015-09-11
    相关资源
    最近更新 更多