1

我正在尝试在 perl 中创建一个 .exe。在我尝试将其编译为 exe 之前,它工作正常。我正在使用 Komodo IDE 5。我已经发布了我的脚本和下面的错误。我已经添加了模块 LWP::UserAgent、NET 和 Google::Voice,但它仍然无法正常工作。我使用 perlapp 创建 .exe

#!/usr/bin/perl -w
use strict;
use warnings;
use Google::Voice;
use Date::Calc qw(Delta_Days);
use Net::Twitter;

#Set Days
    my @today = (localtime)[5,4,3];
    $today[0] += 1900;
    $today[1]++;
    my @RT = (2012, 7, 7);
    my $days = Delta_Days(@today, @RT);

#Get Quotes and Phone Numbers
    open FILE, "c:/Countdown/countdownNumbers.txt" or die "Couldn't open file: $!"; 
    my $numbers = join("", <FILE>); 
    close FILE;
    open FILETWO, "c:/Countdown/Quotes.txt" or die "Couldn't open file: $!"; 
    my $quotes = join("", <FILETWO>); 
    close FILETWO;

#Create Arrays and Lengths
    my @numbersArray = split(/[\n\r\l]+/, $numbers);
    my @quotesArray = split(/[\n\r\l]+/, $quotes);
    my $length = @numbersArray;
    my $QuotesLength = @quotesArray;

#Send Text Message
    for(my $i = 0; $i < $length; $i++){
        my $g = Google::Voice->new->login('secret', 'secret'); 
        $g->send_sms($numbersArray[$i] => "      Countdown\nDays Left: " . $days . "\n Quote:\n" . $quotesArray[0]);
    }


#Send Twitter Message
    my $nt = Net::Twitter->new(
        traits   => [qw/OAuth API::REST/],
        consumer_key        => 'secret',
        consumer_secret     => 'secret',
        access_token        => 'secret',
        access_token_secret => 'secret'
    );
    my $result = $nt->update($days .' Days left!');
    $result = $nt->update('Quote: ' . $quotesArray[0]);

#Rewrite the file and close it
    open FILETWO, ">c:/Countdown/Quotes.txt";
    for(my $i = 1; $i < $QuotesLength; $i++){
        print FILETWO $quotesArray[$i] . "\n";
    }
    close FILETWO;

错误

Algorithm\Diff\XS.pm:
    error: Can't locate Algorithm\Diff\XS.pm
    refby: C:\Perl\site\lib\Array\Diff.pm line 7
Date\Calc\XS.pm:
    error: Can't locate Date\Calc\XS.pm
    refby: C:\Perl\lib\Date\Calc.pm line 26
I18N\Langinfo.pm:
    error: Can't locate I18N\Langinfo.pm
    refby: C:\Perl\lib\Encode\Locale.pm line 51
JSON\PP58.pm:
    error: Can't locate JSON\PP58.pm
    refby: C:\Perl\lib\JSON\PP.pm
Net.pm:
    error: Can't locate Net.pm
    refby: perlapp --add Net::

Can't locate Mojo/EventEmitter.pm in @INC (@INC contains:) at /<C:\Users\Chris\Desktop\Countdown\RT.exe>Mojo/Base.pm line 32.
BEGIN failed--compilation aborted at /<C:\Users\Chris\Desktop\Countdown\RT.exe>Mojo/UserAgent.pm line 2.
BEGIN failed--compilation aborted at /<C:\Users\Chris\Desktop\RTCountdown\RT.exe>Google/Voice.pm line 6.
BEGIN failed--compilation aborted at RT.pl line 4.
4

3 回答 3

3

恐怕将 perl 脚本编译成 exe 文件并不是那么简单。) 查看Perlmonks 的讨论以获取详细信息。

从您引用的内容看来,您可能会开始通过安装其他模块来解决这个问题:Algorithm::Diff::XS、Date::Calc::XS 等。

于 2012-02-25T23:15:43.903 回答
2

如果您使用最新版本的 perlapp,请将此错误发送给 ActiveState 支持。

暂时您可以使用 PAR::Packer 代替 perlapp。使用 cpan shell 安装 PAR::Packer(ppm 可能不起作用)。然后运行

pp -c t1.pl

它将创建一个.out。如果它不起作用,请从 svn 安装 Module::ScanDeps:http ://svn.openfoundry.org/par/Module-ScanDeps/trunk/ - 我为您的程序修复了几个可能的问题。

我从未使用过 perlapp,但它可能有命令行开关来提供要包含的模块列表。

于 2012-02-26T15:53:59.197 回答
1

我已经Langinfo.pmhttp://search.cpan.org/src/RJBS/perl-5.16.1/ext/I18N-Langinfo/Langinfo.pm下载到C:\Perl\lib\I18N并且它可以工作。

  • Komodo IDE,版本 6.1.3
  • Perl 开发工具包专业版 v9.1.1。
  • ActivePerl-5.14.2.1402-MSWin32-x86-295342
于 2012-09-06T07:36:47.570 回答