刚发现,实际上是我太不细心了,把sub d放上来就可以了,顺序问题,应该放在Mainloop上面
use strict;
use warnings;
use threads;
my $cks;
my $url;
my $filename;
my $cks_enter;
my $url_enter;
my $fnm_enter;
sub dd{
#my $thr1 = threads->new(\&d);
#$thr1->join;
d();
}
#my $thr1 = threads->new(\&d);
#$thr1->join;
d();
}
sub d {
$cks = $cks_enter->get();
chomp($cks);
$url = $url_enter->get();
chomp($url);
$filename = $fnm_enter->get();
chomp($filename);
use LWP::UserAgent;
my @headers = (
'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; EN; rv:
1.9.0.11) Gecko/2009060215 Firefox/3.5',
'cookie' => "$cks",
);
chomp($cks);
$url = $url_enter->get();
chomp($url);
$filename = $fnm_enter->get();
chomp($filename);
use LWP::UserAgent;
my @headers = (
'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; EN; rv:
1.9.0.11) Gecko/2009060215 Firefox/3.5',
'cookie' => "$cks",
);
my $ua = LWP::UserAgent->new();
my $req = $ua->get($url,@headers);
my $cont = $req->content;
open PIC, ">$filename";
binmode(PIC);
print PIC "$cont\n";
close PIC;
}
use Tk;
my $req = $ua->get($url,@headers);
my $cont = $req->content;
open PIC, ">$filename";
binmode(PIC);
print PIC "$cont\n";
close PIC;
}
use Tk;
my $mw = MainWindow->new();
$mw->resizable( 0,0 );
$mw->title("test");
$mw->resizable( 0,0 );
$mw->title("test");
my $frame = $mw->Frame(-borderwidth => 2,-relief => 'groove')->pack();
my $bttn = $mw->Button(-text => "Down",-command => \&dd)->pack(-side
=> 'left');
my $bttn = $mw->Button(-text => "Down",-command => \&dd)->pack(-side
=> 'left');
$frame->Label(-text => 'Cookies:')->pack();
$cks_enter = $frame->Entry(-textvariable => \$cks,-width => 50)->pack
();
$cks_enter = $frame->Entry(-textvariable => \$cks,-width => 50)->pack
();
$frame->Label(-text => 'URL:')->pack();
$url_enter = $frame->Entry(-textvariable => \$url)->pack(-expand => 1,
-fill => 'x');
$url_enter = $frame->Entry(-textvariable => \$url)->pack(-expand => 1,
-fill => 'x');
$frame->Label(-text => 'Filename:')->pack();
$fnm_enter = $frame->Entry(-textvariable => \$filename)->pack(-expand
=> 1, -fill => 'x');
MainLoop;
$fnm_enter = $frame->Entry(-textvariable => \$filename)->pack(-expand
=> 1, -fill => 'x');
MainLoop;
--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina Mongers 讨论组"论坛。
要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---
没有评论:
发表评论