./0000700000175000017500000000000011127225664010501 5ustar gregoagregoa./Roman-1.23/0000775000175000017500000000000011122527123012140 5ustar gregoagregoa./Roman-1.23/lib/0000775000175000017500000000000011122527120012703 5ustar gregoagregoa./Roman-1.23/lib/Roman.pm0000664000175000017500000000667011122526703014334 0ustar gregoagregoapackage Roman; use 5.006; use strict; use warnings; our $VERSION='1.23'; =head1 NAME Roman - Perl module for conversion between Roman and Arabic numerals. =head1 VERSION Version 1.20 =cut =head1 SYNOPSIS use Roman; $arabic = arabic($roman) if isroman($roman); $roman = Roman($arabic); $roman = roman($arabic); =head1 DESCRIPTION This package provides some functions which help conversion of numeric notation between Roman and Arabic. =head1 Functions =head2 isroman Tests if argument is valid roman number =head2 arabic roman => arabic =head2 Roman arabic => roman =head2 roman Same as Roman, lowercase =head1 BUGS Domain of valid Roman numerals is limited to less than 4000, since proper Roman digits for the rest are not available in ASCII. Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Roman You can also look for information at: =over 4 =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * RT: CPAN's request tracker L =item * Search CPAN L =back =head1 AUTHOR OZAWA Sakuro 1995-1997 Alexandr Ciornii, C<< >> 2007 =head1 COPYRIGHT Copyright (c) 1995 OZAWA Sakuro. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut use Exporter 'import'; #our @ISA = qw(Exporter); our @EXPORT = qw(isroman arabic Roman roman); our %roman2arabic = qw(I 1 V 5 X 10 L 50 C 100 D 500 M 1000); my %roman_digit = qw(1 IV 10 XL 100 CD 1000 MMMMMM); my @figure = reverse sort keys %roman_digit; #my %roman_digit; $roman_digit{$_} = [split(//, $roman_digit{$_}, 2)] foreach @figure; sub isroman($) { my $arg = shift; $arg ne '' and $arg =~ /^(?: M{0,3}) (?: D?C{0,3} | C[DM]) (?: L?X{0,3} | X[LC]) (?: V?I{0,3} | I[VX])$/ix; } sub arabic($) { my $arg = shift; isroman $arg or return undef; my($last_digit) = 1000; my($arabic); foreach (split(//, uc $arg)) { my($digit) = $roman2arabic{$_}; $arabic -= 2 * $last_digit if $last_digit < $digit; $arabic += ($last_digit = $digit); } $arabic; } sub Roman($) { my $arg = shift; 0 < $arg and $arg < 4000 or return undef; my($x, $roman); foreach (@figure) { my($digit, $i, $v) = (int($arg / $_), @{$roman_digit{$_}}); if (1 <= $digit and $digit <= 3) { $roman .= $i x $digit; } elsif ($digit == 4) { $roman .= "$i$v"; } elsif ($digit == 5) { $roman .= $v; } elsif (6 <= $digit and $digit <= 8) { $roman .= $v . $i x ($digit - 5); } elsif ($digit == 9) { $roman .= "$i$x"; } $arg -= $digit * $_; $x = $i; } $roman; } sub roman($) { lc Roman shift; } 1; # End of Roman ./Roman-1.23/t/0000775000175000017500000000000011122527120012400 5ustar gregoagregoa./Roman-1.23/t/pod.t0000664000175000017500000000022210573122207013351 0ustar gregoagregoa#!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); ./Roman-1.23/t/01.t0000664000175000017500000000063111122526752013017 0ustar gregoagregoa#!perl -T use 5.006; use strict; use warnings; our %test; BEGIN{ %test=( 'I'=>1, 'II'=>2, 'III'=>3, qw/V 5 X 10 L 50 C 100 D 500 M 1000 MCDXLIV 1444 MMVII 2007/ ); } use Test::More tests => (scalar(keys %test)*3); use Roman; while (my ($rom,$arab)=each %test) { ok(isroman($rom),"$rom is roman"); is(arabic($rom),$arab,"$rom is $arab"); is(Roman($arab),$rom,"$arab is $rom"); } ./Roman-1.23/t/pod-coverage.t0000664000175000017500000000026210573122207015146 0ustar gregoagregoa#!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); ./Roman-1.23/t/00-load.t0000664000175000017500000000020610573122207013725 0ustar gregoagregoa#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'Roman' ); } diag( "Testing Roman $Roman::VERSION, Perl $], $^X" ); ./Roman-1.23/MANIFEST0000664000175000017500000000022110573227660013300 0ustar gregoagregoaChanges MANIFEST META.yml # Will be created by "make dist" Makefile.PL README lib/Roman.pm t/00-load.t t/01.t t/pod-coverage.t t/pod.t ./Roman-1.23/Changes0000664000175000017500000000102311122526255013434 0ustar gregoagregoaRevision history for Roman 1.23 18 Dec 2008, Perl 21th birthday version Minimum Perl version required in META.yml 1.22 20 Dec 2007, Perl 20th birthday version Require a new version of Exporter 1.21 26 Nov 2007 Requires 5.006 instead of 5.6.0. Do not subclass Exporter 1.20 10 Mar 2007 Same as 1.10_01 1.10_01 06 Mar 2007 Rewrite by Alexandr Ciornii 1.10 03 Sep 1997 Author's address is now 1.00 01 Sep 1995 ./Roman-1.23/Makefile.PL0000664000175000017500000000130311104547451014115 0ustar gregoagregoause 5.006; use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Roman', AUTHOR => 'Alexandr Ciornii ', VERSION_FROM => 'lib/Roman.pm', ABSTRACT_FROM => 'lib/Roman.pm', PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'Exporter' => 5.57, }, ($ExtUtils::MakeMaker::VERSION ge '6.31'? ('LICENSE' => 'perl', ) : ()), ($ExtUtils::MakeMaker::VERSION ge '6.48'? ('MIN_PERL_VERSION' => 5.006,) : ()), dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Roman-*' }, ); ./Roman-1.23/README0000664000175000017500000000265711122526674013044 0ustar gregoagregoaRoman.pm version 1.23 NAME Roman - Perl module for conversion between Roman and Arabic numerals. SYNOPSIS use Roman; $arabic = arabic($roman) if isroman($roman); $roman = Roman($arabic); $roman = roman($arabic); DESCRIPTION This package provides some functions which help conversion of numeric notation between Roman and Arabic. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install Or use `cpan` or `cpanp` (best way). BUGS Domain of valid Roman numerals is limited to less than 4000, since proper Roman digits for the rest are not available in ASCII. SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc Roman You can also look for information at: Search CPAN http://search.cpan.org/dist/Roman CPAN Request Tracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Roman AnnoCPAN, annotated CPAN documentation: http://annocpan.org/dist/Roman CPAN Ratings: http://cpanratings.perl.org/d/Roman COPYRIGHT AND LICENCE Copyright (c) 1995-1997 OZAWA Sakuro. Copyright (C) 2007-2008 Alexandr Ciornii This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. ./Roman-1.23/META.yml0000664000175000017500000000113311122527123013407 0ustar gregoagregoa--- #YAML:1.0 name: Roman version: 1.23 abstract: Perl module for conversion between Roman and Arabic numerals. author: - Alexandr Ciornii license: perl distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 requires: Exporter: 5.57 perl: 5.006 Test::More: 0 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.48 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4