use Roman; $calc = "II + II"; $calc =~ s/([MDCLXVI]+)/isroman($1) ? arabic($1) : $1/; print eval $calc; #### 2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$