Perl中的语言环境设置是全局的吗? [英] Is locale setting global in perl?

查看:98
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆