Interesting,
I see from your regexp you use a \A and \z, from Perldoc this means:
\A      Match only at beginning of string
\z      Match only at end of string

I am not sure I understand this requirement?

In my case, I am checking an array of 3 scalars. Does this make sense:
next unless @data =~ /$RE {num}{real}/;
Does the regexp know to evaluate each element in the array implicitly? Or do I 
need to tell it this?

Thanks so much!
jlc

-----Original Message-----
From: Xavier Noria [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 18, 2007 3:38 PM
To: Perl List
Subject: Re: Convert Scientific Notation to decimal equivalent



El Jul 18, 2007, a las 11:19 PM, Joseph L. Casale escribió:
> 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?

I am not sure I understand the problem to solve.

You need to filter out lines that contain something that's *not* a
number? If that's the case, is @data a split on whitespace for each
line? If that's the case in turn, have a look at

   perldoc -q determine

or delegate the job to Regexp::Common:

   $ perl -MRegexp::Common -wle 'print 1 if "1.570813E-015" =~ /\A$RE
{num}{real}\z/'
   1

-- fxn


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/







--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to