小编Mih*_*ret的帖子

在 perl 中获取当前语言环境名称

我想在 Perl 中使用数千个 sep。我可以使用以下代码获取它

use strict;
use POSIX qw(setlocale locale_h LC_ALL);
setlocale(LC_ALL, "fr_FR");
my $lc=localeconv();
print $lc->{thousands_sep};
Run Code Online (Sandbox Code Playgroud)

之后,我想将语言环境更改回以前的值,但在使用setlocale. 我应该解析它从$ENV{LANG}哪个设置为 en_US.UTF-8?或者有没有其他方法来获取语言环境名称?

perl locale posix

4
推荐指数
1
解决办法
1500
查看次数

Moose&isa ArrayRef

我试图使用Moose与Moose :: Meta :: Attribute :: Native :: Trait :: Array但它看起来像ArrayRef helper对我不起作用.贝娄是我的代码返回

Can't call method "add_item" on unblessed reference at bug.pl line 42.

我使用Moose 2.0007和Perl v5.10.1.Moose :: Autobox已安装.我将不胜感激任何建议.

#!/usr/bin/perl

use strict;

package CycleSplit;
use Moose;
has 'name'=>(isa=>'Str', is=>'rw');
has 'start'=>(isa=>'Num', is=>'rw');
has 'length'=>(isa=>'Num', is=>'rw');
1;

package Cycle;
use Moose;
my @empty=();
has 'name' => (isa => 'Str', is => 'rw');
has 'splits' => (
    traits  => ['Array'],
    isa=>'ArrayRef[CycleSplit]',
    is = …

perl moose

3
推荐指数
1
解决办法
2145
查看次数

标签 统计

perl ×2

locale ×1

moose ×1

posix ×1