请求帮助!!!(thread)

请求帮助!!!(thread)

请求帮助!!!(thread)
1 运行以下代码出错,请求帮助,多谢多谢!
代码作用:用多个线程扫描机器的1024以下端口。
出错状态:能看见几乎全部运行的运行结果,且结果正确,但最后会出错。
错误信息:Scalars leaked: 1
相关信息:1、perl5.6.1(windows xp sp2 professional)
perl -v 的部分信息:perl, v5.6.1 built for MSWin32-x86-multi-thread
2、在pmm在安装了threads包,该包的信息如下:
threads [0.03] Perl extension allowing use of interpreter based threads from perl

我的猜测:应该使用perl的高版本?请有经验的大虾解答!!!多谢多谢

源码如下:
#!/usr/bin/perl
use strict;
use threads;
use IO::Socket;

my $server = shift || '127.0.0.1';
my $begin = shift || 1;
my $threadnum = shift || 10;

sub startThread{
my ($startPort, $endPort) = @_;

for (my $port=$startPort; $port<=$endPort; $port++) {
my $sock=IO::Socket::INET->new(PeerAddr=>$server,
PeerPort=>$port,
Proto=>'tcp');

if ($sock)
{ print "端口$port可用!!!\n"; }
}
}

my @mythread;
for (my $i=1; $i<=8; $i++) {
$mythread[$i] = threads->create("startThread", ($i-1)*20+1, $i*20);
}
#$mythread[1]

for (my $i=1; $i<=8; $i++) {
$mythread[$i]->join;
}
最好用PERL5.8
#!/usr/bin/perl -w
use strict;
use threads;

my $thread = "argument";
my @THRs;

sub start_thread
{
my $thread = shift;
print "Thread $thread started\n";
};

for ( 1..30 )
{
push @THRs,threads->new(\&start_thread,$thread);
};
$_->join for @THRs;