Why are you capturing to $1? You don't deal with signs, so how about:
sub fconv { my $f = shift; if ($$f =~ m!([\-\+]*)\s*(?:(\d+)\s+)?(\d+)\s*/\s*(\d+)!) { $$f = $2 + $3/$4; $$f = -$$f if $1 eq '-'; } }
cheers
tachyon
In reply to Re^2: Arithmetic with fractions
by tachyon
in thread Arithmetic with fractions
by algonquin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |