谁能给我解释一下,strtod是如何工作的?为什么我会在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发布于 2011-03-10 20:33:02
您的ISO 3166标识符错误。试试US。
https://stackoverflow.com/questions/5257833
复制相似问题