$fraction = '32 2/5'; &fconv(\$fraction); sub fconv { my $f = shift; if ($$f =~ /((\d+) )?(\d+) ?\/ ?(\d+)/) { $$f = $2 + $3/$4; } }