当我将locale
设置为it_IT.UTF-8
(导出LC_ALL = it_IT.UTF-8)并运行此脚本时
#!/usr/bin/env perl
use warnings;
use 5.012;
use POSIX qw(strftime);
say strftime "%A %B %e %H:%M:%S %Y", localtime;
我得到了这个输出:
martedì marzo 15 08:50:07 2011
但阅读此内容(来自The-use-locale-pragma):
By default, Perl ignores the current locale.
The use locale pragma tells Perl to use the current locale for some operations:
...
The POSIX date formatting function (strftime()) uses LC_TIME .
为什么我的语言环境设置会对strftime-output产生影响而不使用locale
pragma?
答案 0 :(得分:5)
POSIX::strftime
是strftime
中使用当前区域设置的真实time.h
C函数调用的瘦包装器。 Perl没有通过努力使其符合。
DateTime has a strftime equivalent符合Perl的语言环境编译指示。