in reply to Re^3: Opening not-existing command - Error Handling
in thread Opening not-existing command - Error Handling
Thanks. You are right. Examining $? helps to know if the child process executed correctly or not.
Here my sample code:
eval { open my $pipe, "perl --version |"; my @res = <$pipe>; close $pipe; }; print "Exit Status: " . ($?>>8);
If I use the not existing command "perl2 --version" then I get the following error message and the exit status 1.
Der Befehl "perl2" ist entweder falsch geschrieben oder konnte nicht gefunden werden. Exit Status: 1
If I use an existing command like "perl --version" then I get the exit status 0 and no error message:
Exit Status: 0
Problem of course is that I then know the error not directly after the open, but only when the child process exited, that means after the close.
|
|---|