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 (Abbot) on Jun 13, 2020 at 13:29 UTC

    oops!