Xavier Noria schreef:
Detecting whether something holds in an array is the job of grep:
my $numbers = grep /\A$RE{num}{real}\z/, @data;
next unless $numbers == @data;
Alternative:
die if grep !/\A$RE{num}{real}\z/, @data;
my $numbers = scalar @data;
--
Affijn, Ruud
Gewoon
El Jul 19, 2007, a las 12:19 AM, Joseph L. Casale escribió:
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?
^ and $ depend on flags,
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
Joseph L. Casale 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
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
=~ /$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
On 7/18/07, Chas Owens [EMAIL PROTECTED] wrote:
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
On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote:
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
Is foo10bar valid? /^$RE{num}{real}$/ says no, but /$RE{num}{real}/
says yes.
Subject: Re: Convert Scientific Notation to decimal equivalent
On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote:
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
Is foo10bar valid
On 7/18/07, Joseph L. Casale [EMAIL PROTECTED] wrote:
Chas,
Sorry but I am not clear on what you mean by reduce? Do you mean
remove all non numbers from the array?
snip
Sort of, the code doesn't modify the original array, it creates a new
array with only the values that are numbers.
--
To
10 matches
Mail list logo