2013-03-23 113 views
1

我正在試圖按here解釋子類MIME::Parser::FileUnder。所以我安裝該模塊:CPAN安裝模塊說OK,但編譯在該模塊上失敗

$ 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"; 
} 

提前感謝!

+0

這是一個文件管理器子類或MIME解析器,所以我想你想的東西就像我的$解析器=新的MIME ::分析器;,然後$ parser-> filer-> output_path(XXX)。 – Analog 2013-03-23 16:53:37

+0

我不明白你的意思。我必須繼承'MIME :: Parser :: FileUnder',如鏈接中所述,使用我自己的'output_path()'。 'GMailMIMEParser'子類'MIME :: Parser :: FileUnder',但它不會識別'MIME :: Parser :: FileUnder' – m0skit0 2013-03-23 17:14:54

回答

0

我只是在做錯誤的事情。我必須子類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"; 
}