perl -e'$|=1;$e=shift;$c=10**$e;$d=int rand$c; $c=0;while($c!=$d){printf"%0${e}d%s",$c,"\b"x$e;$c++} print"$d $c\n"' 10