Perl "pipe" command, cant print binary to handle

D

David

Hey all, I'm working on a script that reads from STDIN. This will
be "use"ed by other scripts. These other scripts may be useing other
lib's which want to read from STDIN as well.
So I've written this code which works great for re-populating STDIN
except for when I try to print binary to the handle.

my $input = join('', <STDIN>);
close(STDIN);
pipe(STDIN, TOSTDIN);
print TOSTDIN $input;
close(TOSTDIN);

in the senario where I get an image file submited via the web, it hangs
when tring to "print TOSTDIN $input;".

Any ideas?

Thanks,
David
 
N

nobull

David said:
pipe(STDIN, TOSTDIN);
print TOSTDIN $input;
it hangs when tring to "print TOSTDIN $input;".

A pipe is a pipe not a storage medium. You can only put so much in
before you have to wait for somthing to start taking stuff out the
other end.

You probably wanted:

open STDIN, '<', \$input;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top