in reply to FileHandle setpos function

See ->seek( pos, SEEK_CUR ) in IO::Seekable. You can record your reference position, grab the index, then setpos(), then SEEK_CUR (which take a relative scalar position).

What getpos() returns is an opaque value that is meaningful only to setpos.

All that said, it sounds like you are doing this the hard way. Building a parser with seek calls seems like... something that you don't really want to do.

Update: minor correction