如何在Perl中将数字转换为文本?

前端之家收集整理的这篇文章主要介绍了如何在Perl中将数字转换为文本?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要在我的程序中使用一些代码作为输入并将其转换为相应的文本,例如745至“七百四十五”.

现在,我可以为此编写代码,但是我可以使用任何库或现有代码吗?

解决方法

来自 Lingua::EN::Numbers的perldoc: @H_403_8@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";

打印:

@H_403_8@You have two hundred and thirty-four things to do today! You will stop caring after the fifty-fourth.

猜你在找的Perl相关文章