I don't understand what you want to do with duplicates. The example
input and output don't seem to match.

You likely want to use a hash.
You can do something like this (untested code):
my %hash;
foreach (@array) {
 my ($run, $in, $out) = split / /; # Split the array element by spaces
 # Count the number of times you have each in and out for each run
 $hash{$run}{'in'}{$in}++;
 $hash{$run}{'out'}{$out}++;
}
foreach my $run (sort {$a <=> $b} keys %hash) { # Loop through the
runs in ascending order
 foreach (sort {$a <=> $b} keys %($hash{$run}{'in'}) {
   print "Run $run, in: $_. count: $hash{$run}{'in'}{$_}\n";
 }
}

On 5/7/07, Nisse Tuta <[EMAIL PROTECTED]> wrote:
Hi All,

I am having big problems solving this sorting issue and would really
appreciate any help on this.

I have a list with each row containing 3 numbers(Run In Out).

For example,
R01 13 19
R01 25 30
R01 23 47
R01 2 14
R02 2 45
R02 55 60
R01 1 17
R03 45 66
R03 20 35
and so on......

I would like to go through these and check for any overlapping numbers
at both In and Out and replacing either the in out or both if
overlapped. And any cuts/breaks in each run will add a count.

To create a list like

Run Count In Out
R01 1 1 19
2 25 47
R02 1 2 45
2 55 60

And so on…..

I hope this make any sense.

Thank you in advance.

Regards,
Nisse


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


Reply via email to