in reply to evaluating fractions

If you want to evaluate them for their value (like 1/4 => .25), you could use eval().

If you want to split them into the numerator and the denominator, you could use split() on the '/' character (assuming that they are simple fractions and not expressions that need more complex evaluation).

"Excellent. Release the hounds." -- Monty Burns.

Replies are listed 'Best First'.
Re: Re: eval
by Anonymous Monk on Dec 20, 2001 at 21:34 UTC
    They are fractions (i.e 1/4 etc) and I do want to evaluate them for there decimal values (i.e 0.25).
    How do I use the eval function to do this ?
    and store each decimal number in a variable of type FRAC [$i][$j]
      $frac = '1/4'; $dec = eval $frac; print "$frac = $dec";

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      You could always look up the eval function to find out.
      why do you need them to be in that format, and what exactly do you mean by it? If all you are looking for is the decimal equiv, just use perl
      $eval = (1/4); print $eval; 0.25
      I may be off the mark, but I hate the way sometimes people try to make this completely obscure code on here when sometimes simple is clearly better. If using eval has a better purpose for THIS PARTICULAR ISSUE, i would love to hear it.