2009年8月3日星期一

[PerlChina] Re: 请教 Tk 和 threads

多谢楼上的
不过 这样一来 threads是不是不用加上了?
非常感谢

On 8月3日, 上午10时00分, langq 235 <langq...@gmail.com> wrote:
> 因为你非常不细心。。。
>
> 你对比一下和你的有什么区别
> #!/usr/bin/perl
> 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->detach();}
>
> use Tk;
> my $mw = MainWindow->new();
> $mw->resizable( 0,0 );
> $mw->title("test");
> my $frame = $mw->Frame(-borderwidth => 2,-relief => 'groove')->pack();
> my $bttn = $mw->Button(-text => "Down",-command => \&d)->pack(-side
> => 'left');
> $frame->Label(-text => 'Cookies:')->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');
> $frame->Label(-text => 'Filename:')->pack();
> $fnm_enter = $frame->Entry(-textvariable => \$filename)->pack(-expand
> => 1, -fill => 'x');
> MainLoop;
>
> 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",
> );
> 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;
>
> }
--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina Mongers 讨论组"论坛。
要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---

没有评论: