推 LiloHuang:如果要用這種方式 可使用 Time::HiRes 模組達到高精度 01/07 23:54
※ 引述《albertliao (~咖啡癮君子~)》之銘言:
: dear all:
: 小弟我最近要用到一個迴圈,當10秒內某個條件未達成便停止,但我找個很久似乎
: perl好像沒有提供timer的module可以讓我去計數時間,請問若要用到timer的功能一定要
: 自己用C寫在弄成module去call嗎,請問有沒有已經有公開的module可以使用或是相關的
: 資訊
: 謝謝
可以使用 time() 但是會有誤差 (精準度只到秒)
#!/usr/bin/perl
$Stamp = time();
print "\n";
for(;;) {
print "\e[A", (time() - $Stamp), "\n";
last if( time() - $Stamp > 9 );
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.232.172.163