我正在嘗試為 Perl 中不超過 2 小時的檔案設定時間戳范圍。從檔案中提取時間的格式為 perl 格式的“May 26 20:30 filename.csv”。
這是我正在設定的內容:
use File::stat;
my $stat = stat($file);
# To start a time within a range or no more than 2 hours
my $start = UnixDate("now", "%m%d %H:%M");
my $stop = UnixDate("$start" 2, "%m%d %H:%M"); // here max it to 2 hours, not sure this part
if ($stat->$start <= $stat->$stop) { next; }
uj5u.com熱心網友回復:
既然你說UnixDate回傳一個紀元時間戳,你所需要的就是:
my $cutoff = time - 2*60*60;
my $file_time = UnixDate( "%m%d %H:%M", $fn );
next if $file_time < $cutoff;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/494022.html
標籤:perl
上一篇:用常量字串替換json物件值
