Zaserov has asked for the wisdom of the Perl Monks concerning the following question:
As I'm new to the language (and programming, really), and this gets used 3 or 4 times per line of a million+ line file, I was wondering if there's a better way or even a built-in command for this. Thanks.sub scicon { my @result; for my $i (0 .. $#_) { my $string_in = $_[$i]; $string_in =~ /(-?\d.\d+)E(.\d+)/; my ($const, $expon) = ($1, $2); $result[$i] = ($const * 10 ** $expon); } return @result; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Conversion from Scientific Notation
by ikegami (Patriarch) on Jul 24, 2009 at 16:54 UTC | |
|
Re: Conversion from Scientific Notation
by JavaFan (Canon) on Jul 24, 2009 at 16:48 UTC | |
|
Re: Conversion from Scientific Notation
by kennethk (Abbot) on Jul 24, 2009 at 16:49 UTC | |
|
Re: Conversion from Scientific Notation
by Zaserov (Novice) on Jul 24, 2009 at 17:04 UTC |