sunshine_august has asked for the wisdom of the Perl Monks concerning the following question:
There are two ways to launch system commands in perl, one is by the system operator, and the other is by the backquotes operator. The system operator can only get the exit status of the command, and the backquotes operator can only get the output of the command.
Sometimes I want to get both the exit status and the output of the command, so I can process the output base on the exit status. Usually I do it by this way: first, launch the command by the system operator to get the exit status, then launch the command again by backquotes operator to get the ouput. But this solution is not that good when launching some network commands, because the network status can be changed between the execution of the two commands.
So, my question is: Is there any way I can get both the exit status and the output of the command without launching it twice?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to get the exit status and the output of the command launched in perl
by zwon (Abbot) on May 26, 2009 at 10:13 UTC | |
by sunshine_august (Scribe) on May 26, 2009 at 10:31 UTC | |
by almut (Canon) on May 26, 2009 at 10:47 UTC | |
Re: How to get the exit status and the output of the command launched in perl
by jwkrahn (Abbot) on May 26, 2009 at 13:14 UTC | |
Re: How to get the exit status and the output of the command launched in perl
by Anonymous Monk on May 26, 2009 at 08:21 UTC |