C:\test>perl -c 632320.pl Global symbol "$i" requires explicit package name at 632320.pl line 17. Global symbol "$i" requires explicit package name at 632320.pl line 17. Global symbol "$i" requires explicit package name at 632320.pl line 17. Global symbol "$i" requires explicit package name at 632320.pl line 18. Global symbol "$i" requires explicit package name at 632320.pl line 22. Global symbol "$i" requires explicit package name at 632320.pl line 22. Global symbol "$i" requires explicit package name at 632320.pl line 22. Global symbol "$i" requires explicit package name at 632320.pl line 23. Global symbol "$i" requires explicit package name at 632320.pl line 24. Global symbol "$i" requires explicit package name at 632320.pl line 24. Global symbol "$i" requires explicit package name at 632320.pl line 25. Global symbol "$i" requires explicit package name at 632320.pl line 34. Global symbol "$i" requires explicit package name at 632320.pl line 34. Global symbol "$i" requires explicit package name at 632320.pl line 34. Global symbol "$i" requires explicit package name at 632320.pl line 35. Global symbol "$inPattQty" requires explicit package name at 632320.pl line 69. Global symbol "$outPattQty" requires explicit package name at 632320.pl line 69. syntax error at 632320.pl line 73, near ") {" 632320.pl has too many errors. #### #/usr/bin/perl -w use strict; use threads; use threads::shared; use Thread::Queue; use Win32::Console; my $CONSOLE = Win32::Console->new(STD_OUTPUT_HANDLE); my $CURRENT_ROW = 3; my @consoleInfo = $CONSOLE->Info(); my $statusRow = $consoleInfo[$CURRENT_ROW]; my $numthreads = 4; my @DataQueues; #There are n+1 queues (mileposts vs. miles). for (my $i = 0; $i <= $numthreads + 1; $i++) { $DataQueues[$i] = Thread::Queue->new; } my @aThreads; for (my $i=0; $i <= $numthreads; $i++) { $aThreads[$i] = threads->new( \&threadprocessor, $DataQueues[$i], $DataQueues[$i+1], $i ); } #put first (empty) solution on the first queue my $hrefSolution = &share({}); $DataQueues[0]->enqueue($hrefSolution); $DataQueues[0]->enqueue(undef); #wait for threads to exit. for (my $i=0; $i<=$#aThreads; $i++) { $aThreads[$i]->join; } #dequeue from the last queue of the chain my $Solutionref; my %Solution; print "\nresults: \n"; while ($Solutionref = $DataQueues[$#DataQueues]->dequeue) { %Solution = %{$Solutionref}; printSolution (\%Solution); } print "\n"; sub printSolution { my $href = shift; print "\nKEYS: "; print(($_).' ') foreach (sort keys %{$href}); print "\nvals: "; print(($$href{$_}).' ') foreach (sort keys %{$href}); print "\n"; } sub isSolution{ 1 } sub threadprocessor { my ($inqueue, $outqueue, $threadNum) = @_; my $inSolnQty = 0; my $outSolnQty = 0; my $statString; my $threadStatusColumn = $threadNum * 12; my $inSolutionref; my %inSolution; my $outSolutionref; my %outSolution; while ($inSolutionref = $inqueue->dequeue) { $statString = sprintf ("%5s/%-5s", $inSolnQty++, $outSolnQty ); $CONSOLE->WriteChar($statString, $threadStatusColumn, $statusRow); %inSolution = %{$inSolutionref}; while (<>) { #ok, I'm hiding complexity here if (isSolution($_)) { #ok, I'm hiding complexity here $outSolutionref = &share({}); %$outSolutionref = (%inSolution); #ok, I'm hiding complexity here $outqueue->enqueue($outSolutionref); $statString = sprintf ("%5s/%-5s", $inSolnQty, $outSolnQty++); $CONSOLE->WriteChar($statString, $threadStatusColumn, $statusRow); } } } $outqueue->enqueue(undef); $statString = sprintf ("%5s/%-5s.", $inSolnQty, $outSolnQty); $CONSOLE->WriteChar($statString, $threadStatusColumn, $statusRow) }