Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical


by mirod (Canon)
on Sep 07, 2000 at 14:38 UTC ( #31374=modulereview: print w/replies, xml ) Need Help??

Item Description: Counting in roman numbers

Review Synopsis: Simple but convenient, limited to 4000


Roman is a module for conversion between Roman and Arabic numerals.

use Roman; $arabic = arabic($roman) if isroman($roman); $roman = Roman($arabic); $roman = roman($arabic);

Why use Roman?

  • to number list item numbers in roman format
  • to display dates in an MPAA approved format

Why NOT use Roman?

  • if you need Roman numbers above 4000 (or if you don't need roman numbers!)

Note: the module does not have a Makefile.PL, so you will have to copy it in your perl module path yourself that should be something like /usr/lib/perl5/site_perl/5.6.0/. Alternatively you can use ExtUtils::MakeMaker to generate a Makefile.PL:

perl -e 'use ExtUtils::MakeMaker; WriteMakefile(NAME => "Roman");'

Personal comments

Roman is a little module that I found when I had to convert Roman numbered lists from XML to HTML. Instead of spending half an hour remembering how those guys counted then writing it myself it took me 5 minutes to install a generic solution. Cool!

I guess now with Unicode being available the module could be upgraded to handle more numbers.

Update: it might look like Dominus does not quite like Roman: is a new contender for stupidest Perl module ever written. but he is actually talking about a different module, one he wrote himself and apparently never submitted to CPAN, which allows you to write things like $IV+$IV and get VIII as a result.

Replies are listed 'Best First'.
Re: Roman
by Willard B. Trophy (Hermit) on Oct 21, 2002 at 19:04 UTC has saved my bacon several times. The best was when I had to replace translation lists marked a, b, c, ... with i, ii, iii, ...

    Roman did exactly what I needed. Trivial example:

    use Roman; while (<DATA>) { chomp; last if (/^$/); my ($key, $data) = split(/\s+/, $_, 2); $key =~ s/([a-z])/roman(1+ord($1)-ord('a'))/eg; print join("\t", $key, $data), "\n"; } exit; __DATA__ a Johan b Gambolputty c von Haukopft d-y (much deleted) z of Ulm

    which gives:

    i Johan ii Gambolputty iii von Haukopft iv-xxv (much deleted) xxvi of Ulm

    Not bad for so litle code and effort, eh?

    foreach(split('',"\3\3\3c>\0>c\177cc\0~c~``\0cc\177cc")) {$_=unpack('B8',$_);tr,01,\40#,;print$_,"\n";}##IYDKINT!

Re: Roman
by stefp (Vicar) on Mar 28, 2001 at 13:25 UTC
    Note that the XML name sounds very much like a roman number. And despite the XML specification claims, XML code is not very human-friendly as well.

    grin :)

    -- stefp

Re: Roman
by mirod (Canon) on Jan 06, 2004 at 18:56 UTC

    I have added a Makefile.PL and tests to Then I added support for numbers above 4000 using Unicode characters.

    As I could not contact the original author, I have put the new version on my web site: Roman 1.3.

    Now I just hope this version will make it to CPAN one day...

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: modulereview [id://31374]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2023-03-30 14:29 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (74 votes). Check out past polls.