2013-06-27 27 views
1

我有一个程序,它为使用HTML :: TagParser和本书的条形码的图书带来了一个页面,抓取一定的跨度,重复它为一个不同的页面,然后添加它到TK :: MListbox直到选择导出它。这在Eclipse中工作得很好。但是,一旦用par-packer制作了一个.exe程序,该程序就无法工作。使用条形码31412007436751时,错误是这样的:URI ::抓包失败时,挤出包装

Tk::Error: URI::Fetch failed: https://i-share.carli.illinois.edu/uis/cgi-bin/shelflister.cgi?search=s1&bcs=31412007436751&bce=&stpt=1&mode=1 at script/ShelfLister_Lister.pl line 32. 
Carp::croak at C:/strawberry/perl/lib/Carp.pm line 100 
HTML::TagParser::fetch at HTML/TagParser.pm line 261 
HTML::TagParser::new at HTML/TagParser.pm line 239 
main::addBook at script/ShelfLister_Lister.pl line 32 
<Key-Return> 
(command bound to event) 

,相关程序代码是这样的:

#!/user/bin/perl 
use strict; 
use warnings; 
use Tk; 
use Tk::MListbox; 
use LWP::Simple; 
use URI::Fetch; 
use Encode::Byte; 
use HTTP::Response; 
use HTML::TagParser; 
use Spreadsheet::WriteExcel; 

my ($callNumber, $title, $html, $numItems); 
my $savetypes = [['Excel Files', '.xls'], ['Comma-Separated Files', '.csv'], ['Text Files', '.txt']]; 
my $mw = new MainWindow; 
$mw->title("Barcode Lister"); 
$mw->Label(-text=>'Choose Books')->grid(-row=>1, -column=>1, -columnspan=>2, -pady=>10); 
my $barcode = $mw->Entry(-width=>50)->grid(-row=>2, -column=>1, -pady=>5, -padx=>[5, 10]); 
my $add = $mw->Button(-text=>'Add Record', -command=>\&addBook, -width=>15)->grid(-row=>2, -column=>2, -pady=>5); 
my $listFrame = $mw->Frame(-bd=>2, -relief=>"sunken")->grid(-row=>3, -column=>1, -padx=>[5, 10], -pady=>5); 
my $list = $listFrame->Scrolled(qw(MListbox -background white -scrollbars oe))->pack(-expand=>1, -fill=>"both"); 
$list->columnInsert('end', -text=>"Call number", -width=>23); 
$list->columnInsert('end', -text=>"Title", -width=>25); 
my $delete = $mw->Button(-text=>'Delete Record', -command=>\&removeBook, -width=>15)->grid(-row=>3, -column=>2, -pady=>5); 
my $export = $mw->Button(-text=>'Export List', -command=>\&exportList, -width=>15)->grid(-row=>4, -column=>1, -columnspan=>2, -pady=>5); 
$barcode->bind('<Return>'=>\&addBook); 
$barcode->focus; 

MainLoop; 

sub addBook{ 
    $html = HTML::TagParser->new('https://i-share.carli.illinois.edu/uis/cgi-bin/shelflister.cgi?search=s1&bcs=' . $barcode->get() . '&bce=&stpt=1&mode=1'); 
    $title = $html->getElementsByClassName('listLine'); 
    if (ref $title){ 
     $html = HTML::TagParser->new('https://i-share.carli.illinois.edu/uis/cgi-bin/shelflister.cgi?search=s1&bcs=' . $barcode->get() . '&bce=&stpt=1&mode=2'); 
     $list->insert("end", [$title->innerText(), $html->getElementsByClassName('listLine')->innerText()]); 
     $barcode->delete(0, 'end'); 
    } 
    else{ 
     $mw->messageBox(-title=>'Error', -message=>"Barcode not found.", -type=>'Ok', -icon=>'error', -default=>'ok'); 
    } 
} 

任何人有我怎么能得到这个作为一个.exe工作任何想法?

回答

1

很可能URI::Fetch->errstr会提供有关失败的更多信息。可以尝试修补HTML :: TagParser(请参阅https://rt.cpan.org/Ticket/Display.html?id=86698),或者也许可以将HTML :: TagParser相关的代码行包装到eval { }中,并在错误时自己调用errstr函数。

+0

对不起,在它接近一年后回来,但这实际上回答了我需要做的,以获得更多的错误信息完美。谢谢。 – user1583044