Ok here's my advanced demo codes

# use strict; # use warnings; use Win32::GUI; use LWP::UserAgent; use HTML::TagParser; use WWW::Mechanize; use URI; use Win32::PingICMP; use threads; use Thread; use Thread::Cancel; use threads::shared; use Data::Dumper; use Thread::Pool::Simple; my (@REVERSESITES, @URLPOOL_th,@URLPOOL_ty); share(@REVERSESITES); # share(@URLPOOL_th); # share(@URLPOOL_ty); my $ua = LWP::UserAgent->new(); $ua->timeout(5); my $agent = WWW::Mechanize->new( 'autocheck' => 1, timeout => 5,'onerr +or' => undef, ); my $p = Win32::PingICMP->new(); # threads->yield(); $ua->agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPat +h.2; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; +.NET CLR 1.1.4322)'); # ------------------------ # GUI AREA # ------------------------ Win32::GUI::Dialog(); sub Win_Terminate {return -1;} sub Button_taramabasla_Click { # START BUTTON PRESSED threads->create(\&asama1); } sub Button_LOAD_Click { # blah blah } sub asama1 { # SECTION 1 (..) # if else blocks push(@GENERALURLPOOL, $result); (..) &asama2(); } sub asama2 { my $google = scalar @GENERALURLPOOL; $Progress_bars->SetRange(0,$google); foreach my $urls (@GENERALURLPOOL) { $Progress_bars->SetStep(1); $Progress_bars->StepIt(); # GETTING RESULTS # parsing all urls and results adding to @GENERALURLPOOL_2 (..) push(@GENERALURLPOOL_2,$urls); (..) } $Progress_bars->SetRange(0,0); $Progress_bars->StepIt(); $Win->RichEdit_1->Append("finished.\r\n"); &asama3(); } sub asama3 { $getsinir = scalar @GENERALURLPOOL_2; $Progress_bars->SetRange(0,$getsinir); foreach $geturl (@GENERALURLPOOL_2){ # parsing urls and results adding to @IPPOOL (..) push (@IPPOOL, $ips); (..) } $Progress_bars->SetRange(0,0); $Progress_bars->StepIt(); $getsinir2 = scalar @IPPOOL; $Progress_bars->SetRange(0,$getsinir2); $Win->RichEdit_1->Append("finished.\r\n"); &GETSHIT(); } sub GETSHIT { sub workder { $ips = shift; # @REVERSESITES shared # lock(@REVERSESITES); Before writing such not printing array elements + in "asama4" subroutine lock(@REVERSESITES); # progress starting (...) if(defined($numbers) || $numbers <=50){ $Win->RichEdit_1->Append("Please wait...\r\n"); while(<while>){ # if else blocks push (@REVERSESITES,$1); } } $Progress_bars->SetStep(1); $Progress_bars->StepIt(); } my $pool2 = Thread::Pool::Simple->new( min => 3, max => 20, do => [\&workder] ); for(@IPPOOL) { $pool2->add($_); } $pool2->join(); $Win->RichEdit_1->Append("Finished.\r\n"); &asama4(); } # OK the problem starts here # 3 problems # -Scalars Leaked : 18 (this is not a big problem) # -Can't call method "STORE" on an undefined # -panic: COND_DESTROY (6). sub asama4 { # ok i'm getting and printing of the array (@REVERSESITES) elements , +lock() is working print $_,"\n" for @REVERSESITES; $getnumm = scalar @REVERSESITES; $Progress_bars->SetRange(0,$getnumm); sub workerss { my $urladdr = shift; $Progress_bars->SetStep(1); $Progress_bars->StepIt(); $ua->get($urladdr); if($ua->content =~ m/content/ig){ push (@URLPOOL, $urladdr); } } use Thread::Pool::Simple; my $pool = Thread::Pool::Simple->new( min => 3, max => 20, do => [\&workerss] ); for(@REVERSESITES){ $pool->add($_); } $pool->join(); $Win->RichEdit_1->Append("Finished.\r\n"); $Progress_bars->SetRange(0,0); $Progress_bars->SetStep(1); # there is big problem @URLPOOL array not printing # lock() function not working, returning with error; "panic: COND_DES +TROY (6)." or "Can't call method "STORE" on an undefined" or just lea +ving the program without errors. print $_,"\n" for @URLPOOL; &asama5(); } # sub test { print "s\n";} sub asama5 { # there is big problem @URLPOOL array not printing print $_,"\n" for @URLPOOL; (....) } sub Button_deletelements_Click {$pass->DeleteAllItems();} sub error { Win32::GUI::MessageBox(0, shift, "Error", 64|0); }

In reply to Re^4: thread::share problem by Anonymous Monk
in thread thread::share problem by merlol

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.