File: README

package info (click to toggle)
libtext-roman-perl 3.5-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 228 kB
  • sloc: perl: 506; makefile: 5
file content (129 lines) | stat: -rw-r--r-- 4,280 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
NAME
    Text::Roman - Allows conversion between Roman and Arabic algarisms.

VERSION
    version 3.5

SYNOPSIS
        #!/usr/bin/env perl
        use strict;
        use warnings;
        use Text::Roman qw(:all);

        print int2roman(123), "\n";

        my $roman = "XXXV";
        print roman2int($roman), "\n" if isroman($roman);

        my $milhar = 'L_X_XXIII'; # = 60,023
        print milhar2int($milhar), "\n" if ismilhar($milhar);

DESCRIPTION
    This package supports both conventional Roman algarisms (which range
    from *1* to *3999*) and Milhar Romans, a variation which uses a bar
    across the algarism to indicate multiplication by *1_000*. For the
    purposes of this module, acceptable syntax consists of an underscore
    suffixed to the algarism e.g. IV_V = *4_005*. The term Milhar apparently
    derives from the Portuguese word for "thousands" and the range of this
    notation extends the range of Roman numbers to *3999 * 1000 + 3999 =
    4_002_999*.

    Note: the functions in this package treat Roman algarisms in a
    case-insensitive manner such that "VI" == "vI" == "Vi" == "vi".

    The following functions may be imported into the caller package by name:

FUNCTIONS
  isroman
    Tests a string to be a valid Roman algarism. Returns a boolean value.

  int2roman
    Converts an integer expressed in Arabic numerals, to its corresponding
    Roman algarism. If the integer provided is out of the range expressible
    in Roman notation, an *undef* is returned.

  roman2int
    Does the converse of "int2roman", converting a Roman algarism to its
    integer value.

  ismilhar
    Determines whether a string qualifies as a Milhar Roman algarism.

  milhar2int
    Converts a Milhar Roman algarism to an integer.

  ismroman/mroman2int/roman
    These functions belong to the module's old interface and are considered
    deprecated. Do not use them in new code and they will eventually be
    discontinued; they map as follows:

    *   ismroman => ismilhar

    *   mroman2int => milhar2int

    *   roman => int2roman

CHANGES
    Some changes worth noting from this module's previous incarnation:

    *namespace imports*
        The call to use must now explicitly request function names imported
        into it's namespace.

    *argument defaults/void context*
        All functions now will operate on $_ when no arguments are passed,
        and will set $_ when called in a void context. This allows for
        writing code like:

            @x = qw/V III XI IV/;
            roman2int() for @x;
            print join("-", @x);

        instead of the uglier:

            @x = qw/V III XI IV/;
            $_ = roman2int($_) for @x;
            print join("-", @x);

SPECIFICATION
    Roman algarisms may be described using the following BNF-like formula:

        a   = I{1,3}
        b   = V\a?|IV|\a
        e   = X{1,3}\b?|X{0,3}IX|\b
        ee  = IX|\b
        f   = L\e?|XL\ee?|\e
        g   = C{1,3}\f?|C{0,3}XC\ee?|\f
        gg  = XC\ee?|\f
        h   = D\g?|CD\gg?|\g
        j   = M{1,3}\h?|M{0,3}CM\gg?|\h

REFERENCES
    For a description of the Roman numeral system see:
    <http://www.novaroma.org/via_romana/numbers.html>. A reference to Milhar
    Roman alagarisms (in Portuguese) may be found at:
    <http://web.archive.org/web/20020819094718/http://www.estado.com.br/reda
    c/norn-nro.html>.

ACKNOWLEDGEMENTS
    This module was originally written by Peter de Padua Krauss and
    submitted to CPAN by Stanislaw Pusep <https://metacpan.org/author/SYP>
    who has relinquished control to Erick Calder
    <https://metacpan.org/author/ECALDER> since the original author has
    never maintained it and can no longer be reached.

    Erick have completely rewritten the module, implementing simpler
    algorithms to perform the same functionality, adding a test suite, a
    Changes file, etc. and providing more comprehensive documentation.

    Ten years later, Stanislaw returned as a maintainer.

AUTHOR
    Stanislaw Pusep <stas@sysd.org>

COPYRIGHT AND LICENSE
    This software is copyright (c) 2003 by Erick Calder <ecalder@cpan.org>.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.