Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

preview a filehandle's next character WITHOUT changing the position of the handle

by chengj86 (Initiate)
on Nov 09, 2011 at 20:27 UTC ( [id://937206]=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://937206]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-18 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found