in reply to Re: Inappropriate ioctl for device error on system call
in thread Inappropriate ioctl for device error on system call

The basic idea is right, but $! won't be set by the command exiting with a nonzero exit status (t will be left at whatever the last error happened to be), and $? is the actual exit value times 256, for a normal exit. See system and $! variable for more details.

Here's an example to try out to see what I mean:

perl -e 'unlink("nosuchfile"); system("sh","-c","exit 1") == 0 or die "Err: $!,$?"' Err: No such file or directory,256 at -e line 1.