[英]How can I convert a number to its English form in Perl?
我需要一個Perl腳本,它將數字作為輸入示例222,它應該輸出為二百二十二 。
使用Lingua :: EN :: Numbers - 將“407”變成“四百七十”等。
use Lingua::EN::Numbers qw(num2en num2en_ordinal);
my $x = 234;
my $y = 54;
print "You have ", num2en($x), " things to do today!\n";
print "You will stop caring after the ", num2en_ordinal($y), ".\n";
打印:
You have two hundred and thirty-four things to do today!
You will stop caring after the fifty-fourth.
如果您閱讀該模塊的文檔 ,那么您會發現該模塊還支持以下內容,例如:
Number :: Spell可以幫到你:
use Number::Spell;
my $str = spell_number(222);
試試這個 。 來自作者......
您可以隨意使用它並根據需要進行修改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.