in reply to Converting percentage into number
Assuming that your percent-values are always preceded by whitespace, and is always a valid numeric, the following should cope with values with and without decimal places:
s/(\S+)%/$1*0.01/eg #e = evaluate right-side as expression, g = global +, i.e. change all percent-values found, not just the first
Tom Melly, pm@tomandlu.co.ukmap{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Converting percentage into number
by Tanktalus (Canon) on Jan 10, 2007 at 15:37 UTC |