in reply to Capture return value from a cmd when it errors

My recommendations: Use system from IPC::System::Simple as a replacement for system with better error handling, use capture from that module as a replacement for backticks with better error handling, or, if you want to also capture the STDERR of an external command, use IPC::Run3.

Capture::Tiny (as recommended by Athanasius) is also a very nice module, but it leaves the execution of the external command and handling of errors up to the user.