Update: My apologies pvaldes. This was not poorly received! I believe I have confused reception to a different post of yours. Probably need new glasses or something. Again, sorry. My original response follows:
pvaldes, thanks for taking the time to reply. As I'm sure you're aware by now, your response has not been well received. Let's see if we can garner something positive from the exercise.
In my original prototype code, I had something which is perhaps on par with what you're suggesting. Rather than digging out old versions, this gives an idea of what it may have looked like:
# TODO - prototype code only!
my @num2word = qw{zero one two ... twenty};
...
say q{I have }, $num2word[$apple_count], q{ apples.};
Moving out of the prototype phase, this code obviously needed to be more robust. I searched around for an existing module without success and, having decided this would be an interesting exercise, came up with the following proof-of-concept:
After ironing out bugs (mostly to do with output format), I put the non-test parts of this code into a module: Util::Number. Having added to @fixed_test_data as I tested, I have values for regression testing (which is still to do as well as POD).
I was surprised that I hadn't been able to find any code like this. I decided to ask here and, if no one had any better ideas, look at putting this functionality on CPAN. You know the rest from this thread.
Here's a quick comparison of the modules mentioned:
$ perl -Mstrict -wE 'use Number::Spell; say spell_number(100010001001)
+'
one hundred billion ten million one thousand one
$ perl -Mstrict -wE 'use Lingua::EN::Numbers qw{num2en}; say num2en(10
+0010001001)'
one hundred billion, ten million, one thousand and, one
$ perl -Mstrict -wE 'use Util::Number; say conv_num_to_text(1000100010
+01)'
one hundred billion, ten million, one thousand and one
In closing, providing something substantial will generally be well received whereas "... add some if and else rules here and there ..." will not. As you can see, while I have thrown a few ifs and elses around, there was nothing in your post that suggested how I should do this.
I recommend you take a look at To Answer, Or Not To Answer.....
P.S. I haven't downvoted your node: I reckon you've got enough bad press already. :-)
|