Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How to preserve the value of STDIN

by Fastolfe (Vicar)
on Sep 22, 2000 at 03:08 UTC ( #33585=note: print w/ replies, xml ) Need Help??


in reply to How to preserve the value of STDIN

Note that this would still destroy STDIN, but at least you have the data available to the two parts of your application that need it. They just need to be re-written to use <$A> and/or <$B> instead of <STDIN>.

You could actually even do without the 2nd variable:

my $A = new IO::String ($data); &exhaust_file_handle($A); # read everything from $A $A->setpos(0); # rewind &also_exhaust($A); # 2nd process reads everything from $A
Since $A isn't a native file handle, you can't seek() on it, but this will do just as well and should be indistinguishable from your two separate processes.

You will also need to do this in a BEGIN { } block, so that all of this mangling of STDIN is done before use CGI ($A) is called.


Comment on Re: How to preserve the value of STDIN
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://33585]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-12-21 13:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (105 votes), past polls