in reply to checking for existence of a file in perl

See file tests in -X:
if (-x file.sh)

For checking return code, see system.