I don't understand something. In
# Test to simulate semaphore growth in Test::Builder.
# Grows by 4 semaphore handles per iteration.
use strict;
use threads;
use threads::shared;
my @Test_Results = (); share(@Test_Results);
sub ok {
my $result = {};
share($result);
push(@Test_Results, $result);
}
my $niter = shift or die "usage: $0 number-of-iterations\n";
ok(1) for 1 .. $niter;
print "Look at handle count in Windows Task Manager\n";
print "Then press [RETURN] to exit...\n";<STDIN>;
As I understand scoping, $result goes out of scope at the end of the call to ok() so why doesn't the handles get released then? Instead the handles don't seem to be released until perl.exe is finished. I guess this is to do with threads and making sure all shared data is available to all threads.