awk: union regions

Hi all,

I have difficulty to solve the followign problem.

mydata:

StartPoint EndPoint
22 55
2222 2230
33 66
44 58
222 240
11 25
22 60
33 45

The union of above regions will turn out:

11-66,222-240,2222-2230

Can someone give suggest an efficient way to do this?

Thanks so much!
Phoeberunner

Can't say I fully understand the requirement, but try...

$ cat file1
22 55
2222 2230
33 66
44 58
222 240
11 25
22 60
33 45

$ awk '{l=length($1);if(!SP[l]||$1<SP[l])SP[l]=$1;l=length($2);if($2>EP[l])EP[l]=$2}END{for(i in SP)print SP "-" EP}' file1|sort|paste -s -d ,
11-66,222-240,2222-2230

$
while(<DATA>){
	my @tmp=split;
	map {my $tmp=length($_); push @{$hash{$tmp}}, $_} @tmp;
}
foreach my $key(sort {$a<=>$b} keys %hash){
	my @tmp = sort @{$hash{$key}};
	print $tmp[0]," <-> ", $tmp[$#tmp],"\n";
}
__DATA__
22 55
2222 2230
33 66
44 58
222 240 
11 25
22 60
33 45
1 6
45678 12345