# 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,'onerror' => undef, ); my $p = Win32::PingICMP->new(); # threads->yield(); $ua->agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.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(){ # 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_DESTROY (6)." or "Can't call method "STORE" on an undefined" or just leaving 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); }