Kalimeister has asked for the wisdom of the Perl Monks concerning the following question:

I am a little confused...
The following code returns "Bad file descriptor" but the file is there and the program runs fine

system ( qq{langcode.exe "$arg1" "$arg2" } ) == 0 or print "\nerror: $!\n";
What exactly does "Bad file descriptor" mean and why would system return that error if langcode.exe does in fact do what it is supposed to do?
Any help would be greatly appreciated.

Kalimeister

Replies are listed 'Best First'.
Re: Returns from using system function
by broquaint (Abbot) on Nov 15, 2001 at 21:59 UTC
    I'm afraid your testing the wrong variable there. Instead of $!, which is what is used when something goes wrong in perl, you want $? which is the return status of system().
    So it seems that the error concerned occured earlier on in your program, which sounds like the result of mishandling your files (it's errno 9 if that's of any help). Then there's also the fact that your system() call is returning a non-zero return code which should probably be of concern.
    HTH

    broquaint

      Thank you for replying...
      The thing that confused me initially was that system() was returning a non zero number - namely 256 which from reading about system() really means 1 so I thought by checking what the value of $! was that would tell me what errno 1 is. If that is not the case then how do I figure out what errno 1 is? and is it possible for you to tell why that kind of error might be happening?
      Thanks again, Kalimeister
        To figure out what the error numbers are, find and read errno.h on your box. It's in /usr/include/asm/ for me. The Errno module may or may not help you.
Re: Returns from using system function
by frankus (Priest) on Nov 15, 2001 at 22:00 UTC
    Don't use $! use $?.
    HTH

    --

    Brother Frankus.

    ¤