- 论坛徽章:
- 32
|
- #!/usr/bin/perl
- my ( $label, $min, $max );
- print scalar <DATA>;
- while (<DATA>) {
- chomp;
- my @line = split /[:-]/;
- if ( $. > 2 ) {
- $max = $line[2] and next if $line[0] eq $label && $line[1] <= $max;
- printf "%s:%d-%d\n", $label, $min, $max;
- }
- $label = $line[0];
- $min = $line[1];
- $max = $line[2];
- }
- printf "%s:%d-%d\n", $label, $min, $max;
- __DATA__
- Name distance
- name1 dis1:1-5
- name1 dis1:2-6
- name1 dis1:7-9
- name1 dis1:10-12
- name1 dis1:11-14
- name2 dis2:5-8
- name2 dis2:6-12
- name2 dis2:7-14
- name2 dis2:14-15
- name2 dis2:17-19
- name2 dis2:20-22
- name2 dis2:21-25
复制代码 |
|