chengj86 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, What i'm trying to do here is to preview the next character in the filehandle WITHOUT changing its position (in a WHILE loop). (so no getc) I have no idea how to do this. anybody knows any tricks??? Thx A LOT! Cheng
  • Comment on preview a filehandle's next character WITHOUT changing the position of the handle

Replies are listed 'Best First'.
Re: preview a filehandle's next character WITHOUT changing the position of the handle
by ikegami (Patriarch) on Nov 09, 2011 at 20:33 UTC

    To my knowledge, the system provides no such call. At best, you can "unread" what you read by seeking back, or by playing with the buffers.

    Update: Actually, linux provides pread: "Read from a file descriptor at a given offset. The file offset is not changed." I don't see any existing modules providing access to it, though. It requires a seekable handle.

      Ignore this. PM is royally screwed up at the moment.