1
我需要得到當前時間與我指定的時區,所以我使用tzset
。但是,當我添加use strict
,我收到以下錯誤不能與「使用嚴格」使用tzset
use strict;
use POSIX qw(tzset);
......................
sub is_active
{
tzset;
$ENV{TZ} = 'America/New_York';
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
if (($hour > 9 && $min > 30) || ($hour < 14))
{
return 1;
}
else
{
return 0;
}
}
Bareword "tzset" not allowed while "strict subs" in use at .......
這是已知的問題?有什麼替代方法可以使用?
您顯示的代碼不會產生任何消息,既不是警告也不是錯誤。問題的根源必須在您未顯示的代碼中。 – PerlDuck
我看,更新。 – user1289
現在我得到'未定義的子程序&my_module :: tzset在......調用......' – user1289