Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I am newbie to this site.

I want to change arabic numbers to roman numbers.

Is there anyway to convert this or any pattern matching.

Thanks for your help!!!

Kone

Replies are listed 'Best First'.
Re: Arabic to Roman Numbers
by gopalr (Priest) on Apr 13, 2005 at 04:54 UTC

    Hi,

    Yes, There is a module to done this job. Module Name is Roman.

    use Roman; foreach (1 .. 100) { print "\n$_=".roman($_); }

    Output:

    1=i 2=ii 3=iii 4=iv 5=v 6=vi 7=vii 8=viii 9=ix 10=x 11=xi 12=xii .... .... ....

    Thanks,

    Gopal.R

      Math::Roman seems to be much more powerful. It subclasses Math::BigInt, which provides it 1) with familiar functions, and 2) with operator overloads allowing the user to do arithmetic on the roman numerals if he desires.

      I haven't used either Roman or Math::Roman modules.

      Yes, There is a module to done this job.

      Actually, and unfortunately, there is more than one. To cite a few:

      Even I created one myself (re-inventing the wheel to gain experience), but I like to think that I was clever enough not to clubber the CPAN with even more duplicated effort (from developers) and additional effort (from users who have to choose which module to use).