1

有人可以解释一下,如何strtod工作。10,2尽管有en_EN-locale ,为什么我会到这里?

#!/usr/bin/env perl
use warnings;
use 5.012;
use POSIX qw(locale_h strtod);

setlocale( LC_NUMERIC, 'en_EN.UTF-8' );

my $str = '5,6';

$! = 0;
my ( $num, $n_unparsed ) = strtod( $str );

if ( $str eq '' or $n_unparsed != 0 or $! ) {
    die "Non-numeric input $str" . $! ? ": $!\n" : "\n";
}

say $num + 4.6;

# 10,2
4

1 回答 1

3

您的 ISO 3166 标识符错误。试试US

于 2011-03-10T12:33:01.753 回答