in reply to can you seek() on STDIN

Hmm.. I probably should have been more clear as to what exactly my problem is.

Simplified is it this: In a CGI script I'm working on I need to read STDIN twice, but unfortunately after reading it once STDIN no longer contains anything; its length is zero. So I'm asking if there is a way to get STDIN back after the first read -- I've tried everything, without success.

--nutshell

Replies are listed 'Best First'.
Re: can you seek() on STDIN
by Abigail-II (Bishop) on May 04, 2003 at 10:11 UTC
    No, you can't read that back. That STDIN comes from a pipe, and pipes aren't seekable. If you can't modify the original code for some reason (which seems strange, because you can modify something or you wouldn't ask this), you can always put it into a wrapper.

    Abigail

Re: can you seek() on STDIN
by Coruscate (Sexton) on May 04, 2003 at 04:39 UTC

    Is there ever really a reason to need to read() from STDIN in a CGI script? Perhaps you want CGI.pm. But why twice? Reading STDIN in CGI once by yourself is a foolish endeavor, let alone twice.


    If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.

      I was trying to work around some rather sticky code. (I can't change the code that does the first read.)

      I guess it's time to give up though.

      --nutshell