Perl 将字符串转换为数字
Perl convert string to numeric number
我想在 perl 中将字符串序数转换为数字
我已经搜索过但没有得到确切的答案。
示例:如果输入是
one it should be 1.
five hundred it should be 500.
three hundred it should be 300.
是否有任何模块可以做到这一点?
Perl 最好的部分之一是 CPAN,果然,在 metacpan turned up the 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");
我想在 perl 中将字符串序数转换为数字 我已经搜索过但没有得到确切的答案。
示例:如果输入是
one it should be 1.
five hundred it should be 500.
three hundred it should be 300.
是否有任何模块可以做到这一点?
Perl 最好的部分之一是 CPAN,果然,在 metacpan turned up the 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");