Hi I am new to threading. So i used Parallel::ForkManager as was suggested that i can use that module for forking of parallel downloads in torrents. My situation was similar to that so i tried it. Can you suggest any changes or modules i can have success. I have also tried the below script.
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Pane; use WWW::Mechanize; use Web::Scraper; use Data::Dumper; use threads; my $mw = tkinit(); $mw->geometry('300x300+100+100'); my $sp = $mw->Scrolled('Pane',-scrollbars=>'osoe',sticky=>'nwse')->pac +k(-expand=>1,-fill=>'both'); $sp->Label(-text=>"Give Keyword file")->pack(); my $entry1 = $sp->Entry()->pack(); my $showbutton = $mw->Button(-text=>'Submit', -command =>\&button_callback)->pack(); my $bimage = scraper { process "img" , "url[]" => '@src'; }; sub button_callback { my $filename = $entry1->get(); open FH, $filename or die $!; while (my $tmpline = <FH>) { my $thr1 = threads->new(\&threadsub($tmpline)); if(threads->list(threads::running)) { print "Waiting for all threads to complete running"; } $thr1->join(); } sub threadsub { my $line =$_; chomp($line); my @temp = split(/ /,$line); my $query = join('+',@tem +p); our $ibing = "http://www.bing.com/images/search?count=10&q=".$query; my $mech = WWW::Mechanize->new; $mech->get($ibing); #print Dumper $mech->content; my $res = $bimage->scrape($mech->content,$mech->uri); print Dumper $res; } close (FH); } MainLoop();
and here is my error: Use of uninitialized value $line in scalar chomp at btest.pl line 34, <FH> line 1. Use of uninitialized value $line in split at btest.pl line 34, <FH> line 1. $VAR1 = {}; Waiting for all threads to complete runningThread 1 terminated abnormally: Not a CODE reference at btest.pl line 26. Free to wrong pool 333f7f0 not 388020 at C:/strawberry/perl/site/lib/Tk/Widget.p m line 98 during global destruction.

In reply to Re^2: Need help in using threads in Tk by mailmeakhila
in thread Need help in using threads in Tk by mailmeakhila

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.