(Go Perl) writes:
> I am having a problem with implementing a simple logic in Perl. The
> following is a file containing the following numbers..
>
> 200 11 36.5
> 11 12 43.5
> 12 212 78.9
> 213 45 56.9
> 45 46 66.8
> 46 47 88.0
> 47 48 89.9
> 48 49 7.8
> 49 215 8.9
>
> Now i want to add up all the numbers between (200,212) and (213,215)
> and so on.
> The numbers i want to add up is the third column for example for
> 200-212 i want to add 36.5,43.5,78.9. And i want to add up stuff only
> if the first column starts with 200 series numbers and the second
> column starts with 200 series numbers.
This is very confusing. You really need to stop and think clearly
about what it is you're trying to do, and explain it better. As it
is, from your description, I can only assume you wouldn't add up *ANY*
of the numbers in the third column of the file.
Using my PSI::ESP module, I guess that you have a file which defines a
set of records. Each set starts with a number of the form '2xx' in
the first column. The second column of that row contains the number
in the first column of the next entry in that set. When the number in
second column is of the form '2xx', then the set is over, and you
should record the start and end numbers of the set, and the total of
the numbers in the third column of each entry in the set, and start
over.
But that's only a guess. Please try to be clearer about what you're
asking for.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.