| 1 | package Convert::Number::Roman; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use utf8; # can't find a way to conditionally load this with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # the scope applying throughout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use vars qw($VERSION %RomanDigits); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | $VERSION = '0.04'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | require 5.000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | %RomanDigits =( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | Ⅰ => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | Ⅱ => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | Ⅲ => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | Ⅳ => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | Ⅴ => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | Ⅵ => 6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | Ⅶ => 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | Ⅷ => 8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | Ⅸ => 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | Ⅹ => 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | Ⅺ => 11, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | Ⅻ => 12, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | Ⅼ => 50, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | Ⅽ => 100, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | Ⅾ => 500, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | Ⅿ => 1000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ↁ => 5000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ↂ => 10000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | sub _setArgs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 190 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setArgs: called CC=8 SCAR=28.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 190 | my ($self, $number, $style) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 190 | ▶ | if ( $#_ > 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | warn ( "too many arguments." ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 190 | ▶ | if ( $number =~ /lower|upper/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $style = $number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $number = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 190 | ▶ | if ( $number ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 190 | ▶ | unless ( $number =~ /^\d+$/ || $number =~ /^[̄̿Ⅰ-ↂ]+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$number =~ /^\d+$/ or $number =~ /^[\x{304}\x{33f}\x{2160}-\x{2182}]+$/
MC/DC0%0/2
$number =~ /^\d+$/ or $number =~ /^[\x{304}\x{33f}\x{2160}-\x{2182}]+$/
$number =~ /^\d+$/
$number =~ /^[\x{304}\x{33f}\x{2160}-\x{2182}]+$/
Truth table66%2/3
A or B
A= $number =~ /^\d+$/B= $number =~ /^[\x{304}\x{33f}\x{2160}-\x{2182}]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | warn ( "'$number' is not a number." ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 190 | $self->{number} = $number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 190 | ▶ | if ( $style ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( $style =~ /lower|upper/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $self->{style} = lc($style); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | warn ( "'$style' is not a supported style, using 'upper'." ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 190 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | my $blessing = bless ( $self, $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | $self->{number} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | $self->{style} = "upper"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | $self->_setArgs ( @_ ) || return if ( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition25%1/4
@_ && ($self->_setArgs(@_) || (return))
$self->_setArgs(@_) or return
MC/DC0%0/2
@_ && ($self->_setArgs(@_) || (return))
@_
$self->_setArgs(@_)
Truth table33%1/3
A && B
A= @_B= $self->_setArgs(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | $blessing; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | sub _fromRoman | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 95 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fromRoman: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 95 | $_ = $_[0]->{number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # convert to uppercase roman: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 95 | tr/ⅰ-ⅿ/Ⅰ-Ⅿ/; # get on up! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # just return if its a single char: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 95 | ▶ | return ( $RomanDigits{$_} ) if ( length($_) == 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # make into math: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # s/̿/̄̄/og; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 84 | s/\x{033F}/\x{0304}/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 84 | ▶ | while ( /[Ⅰ-ↂ](̄+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 88 | my $power = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 88 | my $group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 88 | s/([Ⅰ-ↂ])$power/$group .= $1; "$1$power";/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 88 | s/([Ⅰ-ↂ]$power)+/($group)*($power)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 84 | s/̄/*1000/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 84 | s/Ⅿↂ/+9000/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 84 | s/Ⅿↁ/+4000/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 84 | s/ⅭⅯ/+900/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 84 | s/ⅭⅮ/+400/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 84 | s/ⅩⅭ/+90/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 84 | s/ⅩⅬ/+40/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 84 | s/([ↁⅮⅬ])/+$RomanDigits{$1}/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 84 | s/([ↂⅯⅭⅩ])/+$RomanDigits{$1}/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 84 | s/([Ⅰ-Ⅻ])/+$RomanDigits{$1}/og; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 84 | s/\([+*]/(/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 84 | s/\)\(/\)+\(/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 84 | s/\(([\d+]+)\)/eval"$1"/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 84 | s/^\+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # evaluate the expression: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 84 | eval "$_"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | sub _toRoman | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 219 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_toRoman: called CC=22 SCAR=32.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 219 | my ($self, $number) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 219 | ▶ | $number = $self->{number} unless ( defined($number) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 219 | $number =~ s/^0+//; # strip leading zeros | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 219 | my $roman; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 219 | ▶ | if ( $number >= 40000 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 54 | my $lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 54 | ▶ | while ( $number ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 162 | $number =~ s/(\d{1,3})$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 162 | my $group = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 162 | ▶ | if ( $group != /^0+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 124 | ▶ | if ( $lines ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 88 | my $rGroup = $self->_toRoman ( $group ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 88 | $rGroup =~ s/(.)/$1$lines/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 88 | ▶ | $roman = ( $roman ) ? "$rGroup$roman" : $rGroup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # first cycle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 36 | $roman = $self->_toRoman ( $group ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 162 | $lines .= "̄"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # $roman =~ s/̄̄/̿/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 54 | $roman =~ s/\x{0304}/\x{033F}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 165 | ▶ | while ( $number ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 360 | ▶ | if ( $number >= 10000 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 14 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 16 | $roman .= "ↂ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 16 | $number -= 10000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | elsif ( $number >= 9000 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $roman .= "Ⅿↂ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $number -= 9000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | elsif ( $number >= 5000 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $roman .= "ↁ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $number -= 5000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | elsif ( $number >= 4000 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $roman .= "Ⅿↁ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $number -= 4000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | elsif ( $number >= 1000 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 30 | $roman .= "Ⅿ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 30 | $number -= 1000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | elsif ( $number >= 900 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $roman .= "ⅭⅯ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $number -= 900; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | elsif ( $number >= 500 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 4 | $roman .= "Ⅾ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 4 | $number -= 500; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | elsif ( $number >= 400 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $roman .= "ⅭⅮ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $number -= 400; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | elsif ( $number >= 100 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 128 | $roman .= "Ⅽ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 128 | $number -= 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | elsif ( $number >= 90 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $roman .= "ⅩⅭ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $number -= 90; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | elsif ( $number >= 50 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 4 | $roman .= "Ⅼ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 4 | $number -= 50; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | elsif ( $number >= 40 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | $roman .= "ⅩⅬ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | $number -= 40; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | elsif ( $number > 12 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 43 | $roman .= "Ⅹ"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 43 | $number -= 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | elsif ( $number >= 10 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 64 | $number -= 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 64 | $number =~ tr/0-2/Ⅹ-Ⅻ/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 64 | $roman .= $number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 64 | $number = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 70 | $number =~ tr/1-9/Ⅰ-Ⅸ/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 70 | $roman .= $number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 70 | $number = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 219 | $roman; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | sub upperRoman | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upperRoman: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my ( $self, $roman ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $roman =~ tr/ⅰ-ⅿ/Ⅰ-Ⅿ/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $roman; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | sub lowerRoman | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lowerRoman: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my ( $self, $roman ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $roman =~ tr/Ⅰ-Ⅿ/ⅰ-ⅿ/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $roman; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | sub convert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 190 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
convert: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 190 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # reset string if we've been passed one: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 190 | ▶ | $self->_setArgs ( @_ ) if ( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 190 | ▶ | my $roman | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | = ( $self->number =~ /^[0-9]+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | ? $self->_toRoman | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | : $self->_fromRoman | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 190 | ▶ | ( $self->{style} eq "upper" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ? $roman | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | : $self->lowerRoman ( $roman ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | sub number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 285 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
number: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 285 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 285 | ▶ | $self->_setArgs ( @_ ) || return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%3/4
@_ && ($self->_setArgs(@_) || (return))
$self->_setArgs(@_) or return
MC/DC0%0/2
@_ && ($self->_setArgs(@_) || (return))
@_
$self->_setArgs(@_)
Truth table33%1/3
A && B
A= @_B= $self->_setArgs(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | if ( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 285 | $self->{number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | sub style | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
style: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | $self->_setArgs ( @_ ) || return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
@_ && ($self->_setArgs(@_) || (return))
$self->_setArgs(@_) or return
MC/DC0%0/2
@_ && ($self->_setArgs(@_) || (return))
@_
$self->_setArgs(@_)
Truth table0%0/3
A && B
A= @_B= $self->_setArgs(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | if ( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self->{style}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | ######################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # Do not change this, Do not put anything below this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # File must return "true" value at termination | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | ########################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||