【发布时间】:2017-02-28 07:57:09
【问题描述】:
我想在 perl 中将字符串序数转换为数字 我已经搜索过,但没有得到确切的答案。
例子:如果输入是
one it should be 1.
five hundred it should be 500.
three hundred it should be 300.
是否有任何模块可以做到这一点?
【问题讨论】:
标签: perl perl-module
我想在 perl 中将字符串序数转换为数字 我已经搜索过,但没有得到确切的答案。
例子:如果输入是
one it should be 1.
five hundred it should be 500.
three hundred it should be 300.
是否有任何模块可以做到这一点?
【问题讨论】:
标签: perl perl-module
Perl 最好的部分之一是 CPAN,果然,在 metacpan 上闲逛了几分钟就找到了 Lingua::EN::Words2Nums 模块:
use Lingua::EN::Words2Nums;
$num=words2nums("two thousand and one");
$num=words2nums("twenty-second");
$num=words2nums("15 billion, 6 million, and ninteen");
【讨论】:
15006000019