2012-02-25 82 views
1

我試圖在perl中創建一個.exe文件。它工作正常,直到我嘗試將其編譯爲exe文件。我正在使用Komodo IDE 5.我已經發布了我的腳本和下面的錯誤。我已經添加了模塊,LWP :: UserAgent,NET和Google :: Voice,它仍然不起作用。我用perlapp創建的.exe將Perl腳本編譯爲.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. 
+1

尼斯一票下來,沒有理由 – shinjuo 2012-02-25 22:45:55

回答

3

編譯perl腳本到exe文件不是那麼直截了當,我害怕。 )詳情請查看this discussion at Perlmonks

從你引述似乎什麼,你可能會開始修復與安裝額外的模塊:算法:: DIFF :: XS,日期::計算器:: XS等

+0

我已經添加模塊,它希望它給出了同樣的錯誤不能找到魔/ EventEmitter @INC中的.pm(@INC包含:)在/Mojo/Base.pm第32行。 BEGIN失敗 - 編譯在/ 中終止。 Mojo/UserAgent.pm第2行。 BEGIN失敗 - 編譯在/Google/Voice.pm第6行中止。 BEGIN失敗 - 在RTX.pl第4行編譯異常中止。 – shinjuo 2012-02-27 05:12:45

+0

shinjuou,所以'--add Mojo :: EventEmitter' – obmib 2012-02-27 06:39:24

+0

我也這麼做 – shinjuo 2012-02-27 14:48:43

2

如果你使用最新版本perlapp,將此錯誤發送給ActiveState支持。

暫時你可以使用PAR :: Packer代替perlapp。用cpan shell安裝PAR :: Packer(ppm可能不起作用)。然後運行

pp -c t1.pl 

它會創建a.out。如果它不起作用,請從svn:http://svn.openfoundry.org/par/Module-ScanDeps/trunk/安裝Module :: ScanDeps - 我爲您的程序解決了一些可能的問題。

我從來沒有使用過perlapp,但它可能有命令行開關來提供要包含的模塊列表。

+0

我從來沒有使用PA R :: Packer,它要求我設置GCC環境,我不知道那是什麼,也無法輸入它。還有什麼我需要做的嗎? – shinjuo 2012-02-27 05:11:09

+0

在新版本中,它會自動安裝在舊版本中 - AFAIR可以通過'ppm install gcc'安裝。 – 2012-02-27 13:09:43