in reply to Re: Arithmetic with fractions
in thread Arithmetic with fractions
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Arithmetic with fractions
by TedPride (Priest) on Sep 22, 2004 at 08:07 UTC |