gpt4 book ai didi

html - 如何使用 DateTime 对象执行函数?

转载 作者:可可西里 更新时间:2023-11-01 13:17:49 25 4
gpt4 key购买 nike

我希望我的 .pl 在每天、每周和每月结束时执行一个函数。该函数将在一天结束时从 html 中获取一个整数并将其存储在 .txt 中以用于创建图形。

我已经知道如何用 perl 脚本实现 CGI 和 JS,所以这不是问题。我只是不清楚 DateTime 对象是否可以以这种 bool 类型的方式使用。这听起来很简单,所以我希望有一个简单的答案。

最佳答案

目前还不清楚您的解决方案是否必须是 all-perl。

如果不是 all-perl,您可以使用系统的调度程序 (cron 在 Unix/Linux/MacOS 上,AT 在 Windows 上 pr Windows Scheduler)。

月末,可以每天运行脚本,但在开始的时候,如果不是月末就退出。月末(和周末作为奖励)的逻辑将使用类似的东西:

use Time::Local qw ( timelocal_nocheck ); 
my @time_data = localtime() ;
my $current_dom = $time_data[3];
my $current_dow = $time_data[6];
$time_data[4]++; # Next month.
$time_data[3] = 0; # Last day of previous month.
@time_data = localtime ( timelocal_nocheck ( @time_data ) );
if ($current_dom == $time_data[3]) {
# Do end of month processing
}
if ($current_dow == 0) { # Sunday
# Do end of week processing
}

帽子提示:http://www.perlmonks.org/?node_id=418897

关于html - 如何使用 DateTime 对象执行函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3496374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com