Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Open, ye! And read from your child!

by gryng (Hermit)
on Nov 13, 2001 at 01:42 UTC ( [id://124925]=note: print w/replies, xml ) Need Help??


in reply to Re: Open, ye! And read from your child!
in thread Open, ye! And read from your child!

Doh! You would think a (relatively) seasoned Perl Junkie would have noticed that list context blurp. Ok the new code that works is:

#!/usr/bin/perl -w use strict; if (my $pid = open(READ, "-|")) { print "child said: '", scalar <READ>, "'; ",time,"\n"; print "child said: '", scalar <READ>, "'; ",time,"\n"; } else { $|=1; print "hello; ",time,"\n"; sleep 2; print "how are you; ",time,"\n"; }
And output:
gryn@echor:~$ ./testcase.pl child said: 'hello; 1005597768 '; 1005597768 child said: 'how are you; 1005597770 '; 1005597770

The buffering is necessary, as you all pointed out. However, with the list context problem in the way, I couldn't figure out where to properly put the (de)buffering until it was fixed.

Thanks and kudos to you three,
Gryn

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-25 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found