Perl scripts & Open2

I casually use open2 when I want to pipe to/from various programs. However, when I tried to read/write to one of my perl scripts, it failed to work and it is taking me too long to figure it out, so I am asking you guys. I am attaching a very simple example that I expect to work, but it does not. Running does nothing, the script hangs at my $r=<READ>. What am I doing wrong?
use IPC::Open2;
my $pid=open2 (\*READ, \*WRITE, "./");
binmode WRITE, ":utf8";
foreach (qw(one two three)) {
    print WRITE "$_\n";
    my $r=<READ>;
    print "+$r+\n"
while (<STDIN>) {
    print "*$_*\n";

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


while (<STDIN>) {
    print "*$_*\n";

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ecuadorAuthor Commented:
Simple... thanks!
I wonder why this is not considered worth mentionig in the open2 man pages...
perldoc IPC::Open2
       This whole affair is quite dangerous, as you may block forever.  It
       assumes it's going to talk to something like bc, both writing to it and
       reading from it.  This is presumably safe because you "know" that
       commands like bc will read a line at a time and output a line at a
       time.  Programs like sort that read their entire input stream first,
       however, are quite apt to cause deadlock.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.