Now I modify as some perlmonks threads
#!/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 => \&dd)->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 { #$bttn->configure(-state=>'disabled'); $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; }
When I empty the cookies, and enter a url,click down. It downloads the jpg, but ouccrs some errors:
Attempt to free non-existent shared string '_TK_RESULT_', Perl interpreter: 0x2e3642c at C:/Perl/lib/Tk.pm line 252.
Attempt to free non-existent shared string '_TK_RESULT_', Perl interpreter: 0x2e3642c at C:/Perl/lib/Tk/Widget.pm line 98 during global destruction.
Free to wrong pool 2e33d20 not 284fb0 at C:/Perl/lib/Tk/Widget.pm line 98 during global destruction.
So it maybe something with share? and how to finish it?
Thanks
Best Regards

In reply to Re: how to add threads in the script by go0913
in thread Threads problem with Tk by go0913

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.