http://qs321.pair.com?node_id=768354


in reply to The golf course looks great, my swing feels good, I like my chances (Part I)

After pondering my improved Python algorithm for a while, I was surprised to shave two further strokes from my previous best legitimate Perl solution with this 56 stroker:

$\+=($n="1E@-"%9995)-$\%$n*2while$/=\1,IXCMVLD=~<>;print
Notice that this solution is a strange hybrid of regex and magic formula -- and so perhaps proves both Mtv's law of golf ("regexes always win") and eyepopslikeamosquito's law ("magic formulae always win"). :) Also unusual is that while trumps for on this occasion. The complete list of new Perl solutions I've found since my original post are:
$\+=($n="1E@-"%9995)-$\%$n*2while$/=\1,IXCMVLD=~<>;print $\+=$n-2*$n%($n="1E@-"%9995)while$/=\1,IXCMVLD=~<>;print $\+=$n-2*$\%($n="1E@-"%9995)while$/=\1,IXCMVLD=~<>;print $\+=($n=IXCMVLD=~$_*"1E@-"%9995)-$\%$n*2for<>=~/./g;print $\+=$'-$\%$'*2while$/=\1,I1V5X10L50C100D500M1e3=~<>;print $\+=I1V5X10L50C100D500M1e3=~$_*$'-$\%$'*2for<>=~/./g;print $\+=($n=(IXCMVLD=~$_."E@-")%9995)-$\%$n*2for<>=~/./g;print $\+=($n=VLD=~$_*5+IXCM=~$_."E@-")-$\%$n*2for<>=~/./g;print $\+=M999D499C99L49X9V4I=~$_+$'-2*$\%($'+1)for<>=~/./g;print $\+=($n=10**index(IXCMVLD,$_)%9995)-$\%$n*2for<>=~/./g;print $\+=s//IXCMVLD=~$&."E@-%9995"/ee*$_-$\%$_*2for<>=~/./g;print D6L5V4M3C2X1=~$_,$\+=($n="1E$'"%9995)-$\%$n*2for<>=~/./g;print $\+=$n-2*$n%($n=uppp&7**(9671487%ord()/15)x1)for<>=~/./g;print # update: some more after finding getc $\+=($n=1+substr'004999',"@-",3)-$\%$n*2while VLDMCXI=~getc;print $\+=$'-$\%$'*2while I1V5X10L50C100D500M1e3=~getc;print $\+=($n="1E@-"%9995)-$\%$n*2while IXCMVLD=~getc;print

Update: An improved 74 stroke symref-based solution, after "finding" getc (see below):

$b=++$I;$$_=$b*=$^F^=7for V,X,L,C,D,M; $\+=$n-$\%$n*2while$n=${+getc};print
And here's a quirky 83-stroke PHP version:
<?for($M=2*$D=5*$C=2*$L=5*$X=2*$V=5*$I=1;$n=${fgetc(STDIN)};$t+=$n-2*$ +t%$n)?><?=$t;