in reply to Using system(): converting error num to human readable message

The real problem here is that the messages the shell gives are internal to the shell, and the code the shell chooses to return caller are chosen by the shell.

If the code returned translates directly into a 'system message', and the shell chooses to also report that 'system message', as in the case of "No such file or directory", then perl can translate the code into that same system message.

But, if the shell chooses, given it's intimate knowledge of what you asked it to do, and what error it encountered trying to do it, to report that at a level of detail, or in a manner that for which there is no convenient system message/code, then Perl cannot hope to translate the code returned into the same message the shell produces.

That's a long-winded way of saying, what you are asking for it probably not possible. Consider the case where you passed the same eroneous command to two different shells. Each will produce it's own message, with it's own level of detail. Each will choose what return code to pass back to Perl--they maybe the same or different. Unless they are consistant, and relate to some system message, Perl cannot translate it as you would wish.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."
  • Comment on Re: Using system(): converting error num to human readable message