Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Roman

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

Description

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: Roman.pm 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.

Comment on Roman
Select or Download Code
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 Willard B. Trophy (Hermit) on Oct 21, 2002 at 19:04 UTC
    Roman.pm 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 mirod (Canon) on Jan 06, 2004 at 18:56 UTC

    I have added a Makefile.PL and tests to Roman.pm. 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...

Back to Reviews

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-12-27 02:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls