On 7/18/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote:
How can I detect this, I have been running some code for a few days to
develop some files and ran into the situation where I am getting the
following data for input:
14.95313 14.45312 0
14.95313 1.570813E-015 0
14.95313 -14.45313 0
-14.95313 -28.90625 0
-14.95313 -14.45313 0
-14.95313 1.570813E-015 0
-14.95313 14.45312 0
14.95313 -28.90625 0
0 -28.90625 0
-14.95313 28.90625 0
0 28.90625 0
14.95313 28.90625 0
And my code is skipping some lines as it checks for any erroneous data:
next if grep (/[^0-9.-]/, @data);
But that thinks the scientific notation is bad. I searched the net and
didn't find anything. How can I match this specific pattern and convert it?
Thanks!
jlc
Don't write the regex yourself, use one of the ones in
Regexp::Common*. $RE{num}{real} is probably what you want.
As for how to make "1e3" into 1000, just add 0:
perl -e 'my $i = "1e3"; print $i, " ", $i+0, "\n"';
* http://search.cpan.org/~abigail/Regexp-Common-2.120/lib/Regexp/Common.pm
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/