I'm trying to write a writeoff function using regex
It should work as follows,
writeoff(9.91) => 9.90
writeoff(9.92) => 9.90
.
writeoff(9.94) => 9.90
writeoff(9.95) => 9.95
.
.
writeoff(9.99) => 9.95
Below is the code i tried perl -le '($_=shift)=~s/(\.[0-9])([0-9])/$1(?($2>=5)5|0)/;print' 9.97
OUTPUT
9.9(?(7>=5)5|0)
Please let me know where im doing wrong and other regex implementation of the same
Thanks in advance!!