in reply to computation difficulty

If...

Then...

File can be read in block mode (assign  $/ a reference to block size; see perlvar) and "going back" is just a matter of doing a  seek() by the appropriate negative offset (number of blocks * block size).