in reply to
Sorting the numbers: A little tricky.
I am still not sure I understand your specification. You should test this code with more data to see whether it behaves well in all the border cases:
#!/usr/bin/perl
use warnings;
use strict;
my ($first, $last, $last_small) = ('0e0', 0, 0);
while (<DATA>) {
my ($big, $small) = split;
next if 4 >= $small;
if ($big > $first + 50) {
show($first, $last, $last_small);
$first = $big;
}
$last = $big;
$last_small = $small;
}
show($first, $last, $last_small);
sub show {
my ($first, $last, $last_small) = @_;
print "$first ", $last + 50, " $last_small\n" unless '0e0' eq $fir
+st;
}
__DATA__
109026 3
109027 28
109028 30
116958 15
116960 35
116961 39
116962 70
116963 72
147184 2
147588 1
153087 32