输出: $ perl test_linode.pl downloading http://london1.linode.com/100MB-london.bin 100MB-london.bin 1270110047 1270110047 Illegal division by zero at test_linode.pl line 30.
在 2010年4月1日 下午4:38,Achilles Xu <[email protected]>写道: > 测试代码: > > > use LWP::Simple qw(getstore $ua); > > my @urls = ( > "http://london1.linode.com/100MB-london.bin", > "http://newark1.linode.com/100MB-newark.bin", > "http://atlanta1.linode.com/100MB-atlanta.bin", > "http://dallas1.linode.com/100MB-dallas.bin", > "http://fremont1.linode.com/100MB-fremont.bin" > ); > > my $timeout = 120; > $ua->default_header('Range' => 'bytes=0-1000000'); > for my $url (@urls) { > my ($file) = $url =~ m{/([^/]+)$}; > my $atime = time; > eval { > local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n > required > > alarm $timeout; > my $cmd = "wget $url"; > print "downloading $url $file\n"; > getstore($url, $file); > > alarm 0; > }; > my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, > $atime,$mtime,$ctime,$blksize,$blocks) > = stat($file); > my $btime = time; > print $btime, "\t", $atime, "\n"; > print $url, "\t" . ($size/1000/($btime - $atime)) . "\n"; > if ($@) { > die unless $@ eq "alarm\n"; # propagate unexpected > errors > > # timed > out > > } > else { > # > didn't > > } > } > > 下载文件会需要几秒,但是几秒过去了,atime和btime是一样的,导致后面报出除0错误。 > > 普通笔记本,联想的,intel t4400。 > > 等会试试Time::HiRes有没有问题。 > > -- > --------------------------- > Achilles Xu > > -- --------------------------- Achilles Xu -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
