sub roman { if(split//,pop){$m=$w=$l=0;for(@_){($w|=/[A-Z]/?7:8)<9&&($_={I,1,V,5,X,10,L,50,C ,100,D,500,M,1E3}->{uc$_})||return;if($_>$l&&$l){$q++&&return;$m+=$_-2*$l;$l/=$l =~5?5:2;next}$m+=$l=$_;$q=0}}$m }1;