#!/usr/bin/perl @nums = (1,4,5,9,10,40,50,90,100,400,500,900,1000, 'I','IV','V','IX','X','XL','L','XC','C','CD','D','CM','M'); $cnt = 1999; $rn = "-> "; $n = 12; while($cnt > 0) { while($nums[$n] > $cnt) {$n--;} while($nums[$n] < = $cnt){ $rn .= $nums[$n+13]; $cnt -= $nums[$n]; }; } print "\n", $rn, "\n";