Could this be a job for Tie::File?
In reply to Re: rewinding filehandle/line skipping ? by cjf in thread rewinding filehandle/line skipping ? by Anonymous Monk