#!perl -lp # r() converts an arabic number (1..3999 or -3999..-1) to a roman numeral # using a non-destructive variation of Ton's magic formula (HART). sub r{my$s;($s.=5x$_*8%29628)=~y$IVCXL426(-:$XLMCDIVX$dfor/./g;$s} y/iul-z/-$+/d; # Step 1: convert plus and minus to +$ and -$ s''$'; # Step 1: prepend $ $$_=r(),$$$_=$_ for-3999..-1; # Step 2: build two sets of symbolic references $_=${+eval}; # Step 3: eval the expression