Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nicokaiser
Created October 24, 2012 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicokaiser/3946228 to your computer and use it in GitHub Desktop.
Save nicokaiser/3946228 to your computer and use it in GitHub Desktop.
Conversion from Roman to Arabic numerals
#!/usr/bin/perl
$_=shift@ARGV;s/Mↂ/+9000/g;s/Mↁ/+4000/g;s/CM/+900/g;s/CD/+400/g;s/XC/+90/g;s/XL/+40/g;s/IX/+9/g;s/IV/+4/g;s/ↂ/+10000/g;s/ↁ/+5000/g;s/M/+1000/g;s/D/+500/g;s/C/+100/g;s/L/+50/g;s/X/+10/g;s/V/+5/g;s/I/+1/g;/^[0-9\+]*$/ or die;eval'print 0'.$_;
@nicokaiser
Copy link
Author

usage: ./r.pl MCMLXXXI

@nicokaiser
Copy link
Author

Even shorter version without error handling and support for 10.000 ("ↂ") and 5.000 ("ↁ"): https://gist.github.com/3946249

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment