in reply to Changing numbers into words

Hi webchalkboard, Try this example in module description,

use strict; use warnings; use Lingua::EN::Numbers qw(American); my $n = new Lingua::EN::Numbers(313721.23); print $n->get_string; __END__ Three-Hundred Thirteen Thousand, Seven-Hundred Twenty-One point Twenty +-Three

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Replies are listed 'Best First'.
Re^2: Changing numbers into words
by ikegami (Patriarch) on Apr 06, 2006 at 17:48 UTC
    You appear to be using an obsolete interface. 'American' no longer exists (and it should be 'British' anyway), and num2en is much more appropriate than the object.

    Here's how it would look like using a modern vesion of the module, including the addition of pounds and pence as per the OP's request.

    use Lingua::EN::Numbers qw( num2en ); my $en = num2en(313721.23); my ($pounds, $pence) = split(/ point /, $en); if ($pounds eq 'One') { $pounds .= ' pound'; } else $pounds .= ' pounds'; } $pence ||= 'Zero'; $pence .= ' pence'; $en = "$pounds and $pence"; print("$en\n")

    Untested.