What is the most elegant way to parse an integer given in scientific representation, i.e. I have an input file with lines like
value=1.04738e+06
Sure I can match the all the components (leading digit, decimal positions, exponent) and calculate the result, but it seems to me there is a more straight-forward way.
% perl -e 'print "1.04738e+06" + 0'
1047380
You just need to coerce it to a number and Perl will DWIM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With