Perl中的语言环境设置是全局的吗? [英] Is locale setting global in perl?
问题描述
我正在调试如下所示的perl脚本(简化):
I'm debugging a perl script which looks like this (simplified):
#!/usr/bin/perl
use strict;
use warnings;
use Evil::Module;
printf "%.3f\n", 0.1;
此脚本输出0,100
(请注意,
而不是.
).如果我注释掉use Evil::Module
语句,输出将是0.100
.
This script outputs 0,100
(note ,
instead of .
). If I comment out the use Evil::Module
statement, the output will be 0.100
.
我认为这与模块中的语言环境设置有关.但是语言环境是一个词法编译指示(根据联机帮助页),并且不在脚本中使用.这是怎么回事?
I believe that this is related to locale setting in the module. But locale is a lexical pragma (according to the manpage), and it's not used within the script. What's happening here?
推荐答案
use locale
用法是词法,但是如果Evil :: Module模块使用POSIX::setlocale
,则语言环境更改是全局的.
The use locale
pragma is lexical, but if the Evil::Module module uses POSIX::setlocale
, then the locale change is global.
有关更多信息,请参见 perldoc perllocale
.
See perldoc perllocale
for more information.
这篇关于Perl中的语言环境设置是全局的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!