Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: non-blocking IO from open("-|")ing an external program with fcntl

by jwkrahn (Abbot)
on Jun 12, 2020 at 21:38 UTC ( [id://11118002]=note: print w/replies, xml ) Need Help??


in reply to non-blocking IO from open("-|")ing an external program with fcntl

my $pid = open my $fh, '-|', 'sleep 3; echo aaaa' // die $!;

That will never die because of precedence. (The string 'sleep 3; echo aaaa' is always true.)

$ perl -MO=Deparse -e'my $pid = open my $fh, "-|", "sleep 3; echo aaaa +" // die $!;' my $pid = open(my $fh, '-|', 'sleep 3; echo aaaa'); -e syntax OK

You need to add parentheses:

$ perl -MO=Deparse -e'my $pid = open( my $fh, "-|", "sleep 3; echo aaa +a" ) // die $!;' my $pid = open(my $fh, '-|', 'sleep 3; echo aaaa') // die($!); -e syntax OK

Replies are listed 'Best First'.
Re^2: non-blocking IO from open("-|")ing an external program with fcntl
by bliako (Monsignor) on Jun 13, 2020 at 13:29 UTC

    oops!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (9)
As of 2024-04-18 16:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found