Debian Codegraph @

README

raw
1 NAME
2 Text::Roman - Allows conversion between Roman and Arabic algarisms.
3
4 VERSION
5 version 3.5
6
7 SYNOPSIS
8 #!/usr/bin/env perl
9 use strict;
10 use warnings;
11 use Text::Roman qw(:all);
12
13 print int2roman(123), "\n";
14
15 my $roman = "XXXV";
16 print roman2int($roman), "\n" if isroman($roman);
17
18 my $milhar = 'L_X_XXIII'; # = 60,023
19 print milhar2int($milhar), "\n" if ismilhar($milhar);
20
21 DESCRIPTION
22 This package supports both conventional Roman algarisms (which range
23 from *1* to *3999*) and Milhar Romans, a variation which uses a bar
24 across the algarism to indicate multiplication by *1_000*. For the
25 purposes of this module, acceptable syntax consists of an underscore
26 suffixed to the algarism e.g. IV_V = *4_005*. The term Milhar apparently
27 derives from the Portuguese word for "thousands" and the range of this
28 notation extends the range of Roman numbers to *3999 * 1000 + 3999 =
29 4_002_999*.
30
31 Note: the functions in this package treat Roman algarisms in a
32 case-insensitive manner such that "VI" == "vI" == "Vi" == "vi".
33
34 The following functions may be imported into the caller package by name:
35
36 FUNCTIONS
37 isroman
38 Tests a string to be a valid Roman algarism. Returns a boolean value.
39
40 int2roman
41 Converts an integer expressed in Arabic numerals, to its corresponding
42 Roman algarism. If the integer provided is out of the range expressible
43 in Roman notation, an *undef* is returned.
44
45 roman2int
46 Does the converse of "int2roman", converting a Roman algarism to its
47 integer value.
48
49 ismilhar
50 Determines whether a string qualifies as a Milhar Roman algarism.
51
52 milhar2int
53 Converts a Milhar Roman algarism to an integer.
54
55 ismroman/mroman2int/roman
56 These functions belong to the module's old interface and are considered
57 deprecated. Do not use them in new code and they will eventually be
58 discontinued; they map as follows:
59
60 * ismroman => ismilhar
61
62 * mroman2int => milhar2int
63
64 * roman => int2roman
65
66 CHANGES
67 Some changes worth noting from this module's previous incarnation:
68
69 *namespace imports*
70 The call to use must now explicitly request function names imported
71 into it's namespace.
72
73 *argument defaults/void context*
74 All functions now will operate on $_ when no arguments are passed,
75 and will set $_ when called in a void context. This allows for
76 writing code like:
77
78 @x = qw/V III XI IV/;
79 roman2int() for @x;
80 print join("-", @x);
81
82 instead of the uglier:
83
84 @x = qw/V III XI IV/;
85 $_ = roman2int($_) for @x;
86 print join("-", @x);
87
88 SPECIFICATION
89 Roman algarisms may be described using the following BNF-like formula:
90
91 a = I{1,3}
92 b = V\a?|IV|\a
93 e = X{1,3}\b?|X{0,3}IX|\b
94 ee = IX|\b
95 f = L\e?|XL\ee?|\e
96 g = C{1,3}\f?|C{0,3}XC\ee?|\f
97 gg = XC\ee?|\f
98 h = D\g?|CD\gg?|\g
99 j = M{1,3}\h?|M{0,3}CM\gg?|\h
100
101 REFERENCES
102 For a description of the Roman numeral system see:
103 <http://www.novaroma.org/via_romana/numbers.html>. A reference to Milhar
104 Roman alagarisms (in Portuguese) may be found at:
105 <http://web.archive.org/web/20020819094718/http://www.estado.com.br/reda
106 c/norn-nro.html>.
107
108 ACKNOWLEDGEMENTS
109 This module was originally written by Peter de Padua Krauss and
110 submitted to CPAN by Stanislaw Pusep <https://metacpan.org/author/SYP>
111 who has relinquished control to Erick Calder
112 <https://metacpan.org/author/ECALDER> since the original author has
113 never maintained it and can no longer be reached.
114
115 Erick have completely rewritten the module, implementing simpler
116 algorithms to perform the same functionality, adding a test suite, a
117 Changes file, etc. and providing more comprehensive documentation.
118
119 Ten years later, Stanislaw returned as a maintainer.
120
121 AUTHOR
122 Stanislaw Pusep <[email protected]>
123
124 COPYRIGHT AND LICENSE
125 This software is copyright (c) 2003 by Erick Calder <[email protected]>.
126
127 This is free software; you can redistribute it and/or modify it under
128 the same terms as the Perl 5 programming language system itself.
129