Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Capturing errors from 3-arg pipe open in ActivePerl 5.020

by ateague (Monk)
on Nov 16, 2015 at 17:50 UTC ( [id://1147823]=note: print w/replies, xml ) Need Help??


in reply to Re: Capturing errors from 3-arg pipe open in ActivePerl 5.020
in thread [SOLVED] Capturing errors from 3-arg pipe open in ActivePerl 5.020

Sorry, I feel a bit dense here, but what do I do with the PID once I have it? I get a PID regardless of whether or not the command succeeded.

pipe.pl

#!/usr/bin/perl use 5.018; use strict; use warnings; my $pid = open (my $ARTICLE, "-|", "caesar") or die "Can't start caesa +r: $!\n$^E"; my $read = <$ARTICLE>; say "[$read][$pid]";
Results:
perl pipe.pl 'caesar' is not recognized as an internal or external command, operable program or batch file. Use of uninitialized value $read in concatenation (.) or string at pip +e.pl line 9. [][1236]

Replies are listed 'Best First'.
Re^3: Capturing errors from 3-arg pipe open in ActivePerl 5.020
by Lotus1 (Vicar) on Nov 16, 2015 at 18:53 UTC

    You asked in the OP what is different about your command and why isn't the 'or die' clause working in your open command. I provided documentation that shows if you open a pipe it returns the pid instead of just non-zero or zero like with opening a file. That is the difference and the answer to your question.

    I wasn't telling you to do anything with the pid, only that it is the return value and the reason why your code didn't work as expected.

    I don't think this example should be included in the documentation for open since it doesn't work as expected for pipes.

Log In?
Username:
Password:

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

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

    No recent polls found