我有号码,需要添加后缀:“st”、“nd”、“rd”、“th”。例如:如果数字是 42,则后缀是 'nd' ,521 是 'st' ,113 是 'th' 等等。
我需要在 perl 中执行此操作。任何指点。
Use Lingua::EN::数字::纵坐标 https://metacpan.org/module/Lingua::EN::Numbers::Ordinate。从剧情简介来看:
use Lingua::EN::Numbers::Ordinate;
print ordinate(4), "\n";
# prints 4th
print ordinate(-342), "\n";
# prints -342nd
# Example of actual use:
...
for(my $i = 0; $i < @records; $i++) {
unless(is_valid($record[$i]) {
warn "The ", ordinate($i), " record is invalid!\n";
next;
}
...
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)