in reply to how to convert fractional string to decimal numbers ?
Well, there's the easy (but probably risky) way and the harder (but safer) way to do it. The easy way is just string eval it:
my $strFraction = eval "1/2"; print "strFraction is actually $strFraction <br>";
but consider:
my $strFraction = eval qq|print "this could have been `rm *` - bye bye + files!\n"|; print "strFraction is actually $strFraction <br>";
which prints:
this could have been `rm *` - bye bye files! strFraction is actually 1 <br>
The harder way is to parse the expression, or at the very least untaint it using an appropriate regex if all you accept are simple fractions"
|
|---|