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

does anyone know how to trap return values from a command line in perl?.....this script is doing my head in now!!!!!!

Replies are listed 'Best First'.
Re: trapping return values
by particle (Vicar) on Jul 11, 2001 at 19:54 UTC
Re: trapping return values
by Merlin42 (Friar) on Jul 11, 2001 at 19:54 UTC
    use:
    $return_value = system("command args ...");
    from man perlfunc:
    The return value is the exit status of the program as returned by the `wait' call. To get the actual exit value divide by 256. See also the exec entry elsewhere in this document. This is not what you want to use to capture the output from a command, for that you should use merely backticks or `qx//', as described in the section on "`STRING`" in the perlop manpage. Return value of -1 indi­ cates a failure to start the program (inspect $! for the reason).
Re: trapping return values
by rob_au (Abbot) on Jul 11, 2001 at 19:52 UTC
    Have a look at the perlfunc:system documentation or run a super search ... This topic has been brought up and discussed previously.
     

     
    Ooohhh, Rob no beer function well without!