user491135
user491135

Reputation:

Perl module to transform string number 2.4E+04 to number

I'm parsing a file that contains few numbers noted as 2.4E+04.

I found the module Data::Str2Num that fits on my needs unfortunately Activeperl doesn't have it compiled to 5.16, only for 5.8 and I'm bounded to use 5.16 from Activeperl as it is the exact same version for production (I cannot use anything outside the ppm).

Is there any module like Data::Str2Num that does the same in the newer versions?

UPDATE:

Inside a script you can do my $value = "2.4E+04" + 0;

Upvotes: 2

Views: 239

Answers (1)

RobEarl
RobEarl

Reputation: 7912

Evaluate it in a numeric context:

perl -e 'print "2.4E+04" + 0;'
24000

Upvotes: 5

Related Questions