in reply to could not open c

This test:

if ($result >> 0)

should be

if( ( $result >> 8 ) != 0 ) {

Or more simply:

if( $result >> 8 ) {
If that doesn't fix your problem, then you will need to print out the failure code (print $result >> 8) and then look that up in the documentation for the executable to determine what the errorcode means.

Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.