#!/your/perl/here use strict; use warnings; my $string = < $offset ) { $hi = $line; } elsif ( $lookup[$line] < $offset ) { $lo = $line; } else { # small chance it's equal last; } } # could have overshot 1 if ( $lookup[$line] > $offset ) { $line--; } if ( $lookup[$line+1] > $offset ) { # this is the one my $line_offset = ($offset - $lookup[$line]); return ($line, $line_offset); } else { return; } }