in reply to Sorting the numbers: A little tricky.
Your problem is poorly specified. When we have to make guesses as to how to derive your output from your input, it is likely that we will guess the simplest thing that could possibly work and do that, or, more likely, just ask for clarification. Since there have already been several of the latter, I'll take a shot at the former.
Using the following specs - for a file with 2 columns of numbers; let's call them pointer and value:
If it was me, I would do something like:
use warnings; use strict; my ($start, $lastp, $lastv); while ( my $line = <DATA> ){ my ( $pointer, $value ) = split /\s+/, $line; flush() if ( $value <= 4 or $value > 4 && $value < $lastv ); $start = $pointer unless ( defined $start || $value <= 4 ); ( $lastp, $lastv ) = ( $pointer, $value ); } flush(); sub flush { if ( defined $start ){ printf "%d %d (which is %d + 50) %d\n", $start, $lastp + 50, $ +lastp, $lastv; } undef $_ for ( $start, $lastp, $lastv ); } __DATA__ 109026 3 109027 28 109028 30 116958 15 116960 35 116961 39 116962 70 116963 72 147184 2 147588 1 153087 32
Yields:
109027 109078 (which is 109028 + 50) 30 116958 117013 (which is 116963 + 50) 72 153087 153137 (which is 153087 + 50) 32
|
---|