in reply to Re^2: usage of $? in windows
in thread usage of $? in windows
$? == 256 means the child called exit(1) (256>>8 = 1). Chances are that the value (1) is not significant beyond meaning an error occurred. You'd think it would have emitted a message to STDERR identifying the error.
$ perl -le'qx{date abc}; print $?' date: invalid date `abc' 256
One likely cause is improper escaping of arguments. Print out $cmd, check for bad quoting, and try that same command at the prompt.
$ perl -le'qx{cat some file}; print $?' cat: some: No such file or directory cat: file: No such file or directory 256 $ perl -le'qx{cat "some file"}; print $?' 0
You mentioned the child is some kind of searching utility. An error could also indicate no matches were found.
$ perl -le'qx{echo foo | grep bar}; print $?' 256 $ perl -le'qx{echo foo | grep foo}; print $?' 0
The program's man page might identify situations where it might return an error.
|
|---|